ENG1003 Lecture Notes - Lecture 9: Jslint, Web Service, Asteroid Family

66 views7 pages
!"#$%&'%()"*()*#$+ ,&-(.)&/*012(",&34&$($*)"*&"/#$-"(22&2).-(/(,*)
5&)*'6"-&$("#$"17*&31*(- /1)8#&$
9&/*012("2(+7'12'6"(:(,7*()"*()*)"*&"/#$-"#))7()
;
<731$)",2(1*("*()*",1)()
;
=&231'"*()*#$+"42&,())()"#34* >(,17)(?
@&34'#,1*(- A31$6"-#//(2($*"4&))#>'("(%($*71'#*#()"*81*"*1B("#$*&"
,&$)#-(21*#&$.,&4("0#*8"1''"*8("016)"1"7)(2"#$*(21,*)"0#*8"#*"1$-"*8("
-1*1"*8(6"#$47*
;
9&/*012("144)"12(",&34'(: )6)*(3)"&/"#$*(21,*#$+",&34&$($*)"41))#$+"
3())1+()"1$-"#$/&231*#&$">(*0(($"(1,8"&*8(2
C7+) #$"&$(",&34&$($*",1$"(1)#'6"31$#/()*"1)")7>*'("42&>'(3)"#$"
1$&*8(2
D2&>'(3)"#$")&/*012("812-"*&"*21,B -&0$"1$-",&22(,*
;
E%(2"(%&'%#$+
F/*($"3&-#/#(-"AAG"(1)#'6"'(1-"*&"$(0">7+)
;
Methods?
Static *()*#$+"!"1442&1,8()"*81*"*()*"*8("
,&-(.144'#,1*#&$"0.&"27$$#$+"#*
@&-("2(%#(0 !"'&&B#$+"*82&7+8",&-("%#)71''6"1$-"
)(12,8#$+
;
H1'B*82&7+8 !"/&''&0#$+"1"42&,())"1$-"'&&B#$+"
/&2"42&>'(3",1)()
I)#$+")&72,(",&-("&2"*(,8$#,1'"-&,73($*"
-(),2#>#$+"42&,())"#$"J7()*#&$
;
Dynamic *()*#$+"!"1442&1,8()"*81*"4(2/&23"*()*)"&$"
27$$#$+",&-(
@1''#$+"#$-#%#-71'"/7$,*#&$) 0#*8")4(,#/#,"#$47*"
1$-",8(,B#$+"2(*72$"%1'7()
KLK")4(,#/6#$+"21$-&3"#$47*)"1$-"'&&B#$+"
/&2"(22&2).,21)8()
;
9#37'1*#$+ +()*72()"1$-"*14)"&/"7)(2"#$*(21,*#&$
;
Approaches to3testing:
Black3box3testing
!"*()*#$+",&-("08#'("B$&0#$+"081*"#*"#)")744&)(-"*&"-&">7*"$&*"8&0 #*"#)"
-&$(
!"+#%#$+">'1,B">&:"1")(*"&/"#$47* 1$-"%(2#/6#$+ *81*"#*"42&-7,()"1"412*#,7'12"
)(*"&/"&7*47*
M(+N")#**#$+"#$",12"0#*8&7*"B$&0#$+"8&0"($+#$("0&2B)O
@2(1*(-"-#2(,*'6"/2&3")&/*012("2(J7#2(3($*);
F21,'( !"P-#,*#&$126P"&/"2#+8*">(81%#&72"&/")&/*012("#$"1"412*#,7'12")#*71*#&$
E+N")&/*012(")4(,#/#,1*#&$Q"(:#)*#$+"1'+&2#*83Q"42(%#&7)"%(2)#&$"&/",&-(;
9&72,(",&-("$&*")(($;
9&/*012(",&34&$($*"!">'1,B">&:"M,1$R*")(("#$)#-(O;
White3box3testing3(or3"clear3box3testing")
!"1442&1,8"08(2("*()*)"12("02#**($"B$&0#$+"8&0 *8("*()*(-",&-("0&2B)
C1)(-"&$")*27,*72("1$-"-()#+$"&/",&-(;
@1$"*()*"#$-#%#-71'",&-("41*8)Q"21$+()"&/"%12#1>'()Q"-1*1"*64() 7)(-"
(*,N
;
M(+N")#**#$+"#$"1",12"08#'(")((#$+"7$-(2"1$-"7$-(2)*1$-#$+"*8(",&34&$($*)"
7$-(2"*8(">&$$(*"1$-"8&0"*8(6"12(",&$$(,*(-O
S()*#$+"levels?
I$#*"AAG"
T$*(+21*#&$"AAG"
96)*(3
S()*#$+"approaches?
C'1,B">&:
H8#*(">&:
Static:3(-->3analysis)
@&-("2(%#(0
H1'B*82&7+8
Dynamic:
@1''#$+"#$-#%"/7$,*$)
9#37'1*#$+"7)(2"#$*N
*Static3analysis
!"1"/&23"&/")*1*#,"*()*#$+"*81*"#$%&'%()"17*&31*#,"1$1'6)#)"&/"*8(",&-("*&"
-(*(23#$("4&))#>'("#))7()
H.F"UIVVTVW"TSN
@&-("2(%#(0"-&$(">6"1",&347*(2"M(+")6$*1:"(22&2)"'#B("3#))#$+"
)(3#,&'&$)O
;
9&3(*#3()",1$")7++()*"42&>'(3)"*81*"12($R*"2(1''6"42&>'(3);
F/*($"4(2/&23(-",&$*#$7&7)'6">6",&-("(-#*&2.TXE"MT$*(+21*(-"
X(%('&43($*"E$%#2&$3($*O
C21,B(*)?"Y9Z#$*
E+N"
var
number = 3;
if
(number = 4)
{
console.log("Is 4");
}
Line 3: Expected a conditional expression and instead
saw an assignment.
;
Coverage3testing
!"27$$#$+"1")4(,#1'"*&&'"*81*"(:(,7*()" 144"31$6"*#3()Q"#-(1''6"7)#$+"
1''"1%1#'1>'("*()*",1)()
H8#'("-&#$+"*8#)Q",&7$*)"8&0"31$6"*#3()"(1,8"'#$("&/")&72,("
,&-("#)"(:(,7*(-
I)71''6"&7*47*)"1$$&*1*(-"%(2"&/")&72,(",&-("0."
(:(,7*#&$",&7$*
E$)72()"*()*",1)()"81%("[\\]",&%(21+("&/",&-(
§
T/"$&*Q
T))7()"#$"7$*()*(-",&-(^
X1$+(2"*81*")&3(&$("3&-#/#()"7$*()*(-"
,&-("1$-"#$*2&-7,()">7+"0.&"$&*#,#$+
^
§
;
_(:*($)#%("17*&31*#,"*()*#$+Q"#$,'7-#$+"*8&7)1$-)"&/"2(+2())#&$"*()*)"/&2"
,&22(,*$())"1$-"4(2/&231$,(O
@81$+#$+")&/*012(",1$"(1)#'6"#$*2&-7,("$(0">7+)"&2",17)("&'-">7+)"*&"
2(144(12
9F"31$6")&/*012("($+"42&`)"2(J",2(1*#&$"&/"**regression3tests3M!"1--#$+"
*()*)"*&"27$"&$",&-("*&",8(,B"#*"0&2B)"42&4(2'6Q"*82&7+8&7*",&$)*27,*#&$"&/"
,&-(O 1)"412*"&/">7+"/#:#$+"42&,())"CODE3SNIPPETS
C7+"#)"#-($*#/#(-"M(+"/23",7)*&3(2"2(4&2*#$+"42&>'(3O[N
F$("($+#$((2"0#''"02#*("*()*",1)(")8&0#$+"42&>'(3"AAG"08#,8"*8($"
/1#')
aN
D2&>'(3"#)"/#:(-"#$")&72,(",&-("
K''"2(+2())#&$"*()*)"27$"M/&2"(1,8"$(0",81$+("*&",&-(">1)(O
@1$",1*,8")#*71*#&$)"08(2("1",81$+("*&"&$(",&34&$($*"
#$-#2(,*'6">2(1B)"1$&*8(2"4#(,("&/",&-(
#N
@1$"/#$-"08(2("1"42(%#&7)'6"&,,722#$+"#))7("2(144(12)##N
1N
F/*($"4(2/&23(-"17*&31*#,1''6"#$"2()4&$)("*&"(%(26",&33#*"*&"
42&`"2(4&
CN
9&3(*#3()",81$+()"12($R*"1''&0(-"*&">(",&33#**(-"7$*#'"*8(6"
41))"1''"*()*)
@N
bN
AAG"41))()
S8("'12+(2" *8(")6)*(3Q"*8("3&2("#$*(21,*#&$)">*0$"-#//",&34&$($*)"&/"
)&72,(",&-(Q"*8("3&2("*8#$+)"+&"02&$+
U(-7,#$+"2#)B"*&"\"#)"$&*"4&))#>'(N
@1$">("42(%($*(-"7)#$+")4(,#/#,"1,,(4*1$,(",2#*(2#1 /&2"7)(2")*&2#()N"M(+N"
21,(,12"1$-"U1,(,12 AAG"4&))#>'(")&'7*#&$"0&7'-">(",81$+#$+"744(2,1)("*&"
'&0(2,1)(">(/&2("*()*#$+O
Levels of3testing
Unit3testing
!")*2())"7$#*)"M)31''"4&2*#&$)O"&/",&-(
W($(21''6"*()*)"/7$,*#&$ M3(*8&-"&/"1",'1))Q"#$",1)("&/"FAFO;
I)71''6"02#**($ >6")&/*012("($+"08#'("#34'(3($*#$+ *81*"4&2*#&$"&/",&-(;
E+?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Unit tests for isPalindrome() function
//
function
TestIsPalindrome()
{
// Public methods (test cases):
this
.oddLengthTest =
function
() {
runTest("racecar",
true
, "oddLengthTest");
};
this
.evenLengthTest =
function
() {
runTest("hannah",
true
, "evenLengthTest");
};
this
.oneCharacterTest =
function
() {
runTest("a",
true
, "oneCharacterTest");
};
this
.caseTest =
function
() {
runTest("Hannah",
true
, "caseTest");
};
this
.emptyStringTest =
function
() {
runTest("",
true
, "emptyStringTest");
};
this
.firstCharacterDifferentTest =
function
() {
runTest("aacecar",
false
,
"firstCharacterDifferentTest");
};
// Iterates over all public methods and calls
each one whose name
// ends in "Test". Saves us having to call
each one individually.
//
this
.runAllTests =
function
() {
for
(
var
methodName
in this
)
{
if
(methodName.endsWith("Test"))
{
var
method =
this
[methodName];
if
(
typeof
method === "function")
{
// Call the test method.
method();
}
}
}
}
// Private methods (support code):
var
runTest =
function
(input, expectedOutput,
testName) {
var
output = isPalindrome(input);
var
passed = expectedOutput === output;
if
(passed)
{
console.log('[PASS] ' + testName);
}
else
{
console.log('[FAIL] ' + testName + ':
isPalindome("' + input + '") !== ' +
expectedOutput);
}
};
}
// Perform the tests.
var
test =
new
TestIsPalindrome();
test.runAllTests()
// Returns true if the given text String is a
palindrome, false otherwise.
//
function
isPalindrome(text)
{
// For every character from beginning to middle
of text,
// compare it to corresponding character at the
end of text.
for
(
var
i = 0; i < (text.length / 2); i++)
{
if
(text[i] != text[text.length -1 -i])
{
// Character pair doesn't match, not a
palindrome.
return false
;
}
}
// All character pairs matched, is a
palindrome.
return true
;
}
ccS&"*()*"1",'1))"#$)*(1-"&/"1"/7$,*#&$Q",2(1*("1")#3#'12"*()*",'1))N
E1,8"*()*",1)("3(*8&-"#$"*8("*()*",'1))"0&7'-?
@2(1*(",'1))"#$)*1$,("&/",'1))"*&">("*()*(-;
@1''"!G["3(*8&-)"&$"*81*"#$)*1$,("*&",81$+("#*)")*1*(;
@1''")&3("&*8(2"3(*8&-)"*&",8(,B"*8(")*1*("&/"*8(",'1))"#$)*1$,("1$-"
,&3412("*&"(:4(,*(-"&7*,&3(
;
Integration3testing
!"(:13#$(">(81%#&72"1$-",&33 >*0$"!Ga")6)*(3",&34&$($*)
@8(,B)">(81%#&72"&/",&34&$($*)"1+1#$)*"-&,73($*1*#&$ M7)71''6"81%("
0(''A-(/"#$*(2/1,()O
@&34&$($*)"!"*0&",'1))()"7)(-"*+*d"1",'1))"*81*",&33)"0#*8"1"0(>"
)(2%#,(
;
S12+(*)">7+) *81*",&7'-"(3(2+("08($"M)7>O)6)*(3) _*81*"0&2B"4(2/(,*'6"
#$"#)&'1*#&$e",&&4(21*( 0#*8"(1,8"&*8(2
;
M(+N"-1*1"'16(2"&/"1"3&>#'("144"*81*",&337$#,1*()"0."S0#**(2"1$-")*&2()"*8("
'&,1'"%(2"&/"1")(*"&/"#$/&"/23"S0#**(2"0(>)#*(
AAG",2(1*(",&-("*81*"2(*72$)")134'("-1*1"#$"*8(")13("/&231*"1)"S0#**(2"
0(>")(2%#,(O
@122#(-"&7*"K=SEU"7$#*"*()*#$+"#)")7,,())/7';
System3testing
!"*()*#$+"*8(",&34'(*( 144'#,1*#&$"#$"&2-(2"*&",8(,B"*81*"#*")1*#)/#()"#*)"2(J)
S()*)",2(1*(-"/2&3"7)(2")*&2#()"FU"1,*#%#*6"-#1+213)",2(1*(-"-72#$+"
-()#+$
@8(,B"/&2",&22(,*">(81%#&72
@8(,B"/&2"7$01$*(-">(81%#&72"(+N",21)8#$+Q"'&)#$+"7)(2"-1*1
;
Week$9:$Software$Verification
=2#-16Q"af"K42#'"a\[g
[h?[a
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 7 pages and 3 million more documents.

Already have an account? Log in
!"#$%&'%()"*()*#$+ ,&-(.)&/*012(",&34&$($*)"*&"/#$-"(22&2).-(/(,*)
5&)*'6"-&$("#$"17*&31*(- /1)8#&$
9&/*012("2(+7'12'6"(:(,7*()"*()*)"*&"/#$-"#))7();
<731$)",2(1*("*()*",1)();
=&231'"*()*#$+"42&,())()"#34* >(,17)(?
@&34'#,1*(- A31$6"-#//(2($*"4&))#>'("(%($*71'#*#()"*81*"*1B("#$*&"
,&$)#-(21*#&$.,&4("0#*8"1''"*8("016)"1"7)(2"#$*(21,*)"0#*8"#*"1$-"*8("
-1*1"*8(6"#$47*
;
9&/*012("144)"12(",&34'(: )6)*(3)"&/"#$*(21,*#$+",&34&$($*)"41))#$+"
3())1+()"1$-"#$/&231*#&$">(*0(($"(1,8"&*8(2
C7+) #$"&$(",&34&$($*",1$"(1)#'6"31$#/()*"1)")7>*'("42&>'(3)"#$"
1$&*8(2
D2&>'(3)"#$")&/*012("812-"*&"*21,B -&0$"1$-",&22(,*
;
E%(2"(%&'%#$+
F/*($"3&-#/#(-"AAG"(1)#'6"'(1-"*&"$(0">7+)
;
Methods?
Static *()*#$+"!"1442&1,8()"*81*"*()*"*8("
,&-(.144'#,1*#&$"0.&"27$$#$+"#*
@&-("2(%#(0 !"'&&B#$+"*82&7+8",&-("%#)71''6"1$-"
)(12,8#$+
;
H1'B*82&7+8 !"/&''&0#$+"1"42&,())"1$-"'&&B#$+"
/&2"42&>'(3",1)()
I)#$+")&72,(",&-("&2"*(,8$#,1'"-&,73($*"
-(),2#>#$+"42&,())"#$"J7()*#&$
;
Dynamic *()*#$+"!"1442&1,8()"*81*"4(2/&23"*()*)"&$"
27$$#$+",&-(
@1''#$+"#$-#%#-71'"/7$,*#&$) 0#*8")4(,#/#,"#$47*"
1$-",8(,B#$+"2(*72$"%1'7()
KLK")4(,#/6#$+"21$-&3"#$47*)"1$-"'&&B#$+"
/&2"(22&2).,21)8()
;
9#37'1*#$+ +()*72()"1$-"*14)"&/"7)(2"#$*(21,*#&$;
Approaches to3testing:
Black3box3testing
!"*()*#$+",&-("08#'("B$&0#$+"081*"#*"#)")744&)(-"*&"-&">7*"$&*"8&0 #*"#)"
-&$(
!"+#%#$+">'1,B">&:"1")(*"&/"#$47* 1$-"%(2#/6#$+ *81*"#*"42&-7,()"1"412*#,7'12"
)(*"&/"&7*47*
M(+N")#**#$+"#$",12"0#*8&7*"B$&0#$+"8&0"($+#$("0&2B)O
@2(1*(-"-#2(,*'6"/2&3")&/*012("2(J7#2(3($*)
;
F21,'( !"P-#,*#&$126P"&/"2#+8*">(81%#&72"&/")&/*012("#$"1"412*#,7'12")#*71*#&$
E+N")&/*012(")4(,#/#,1*#&$Q"(:#)*#$+"1'+&2#*83Q"42(%#&7)"%(2)#&$"&/",&-(
;
9&72,(",&-("$&*")(($
;
9&/*012(",&34&$($*"!">'1,B">&:"M,1$R*")(("#$)#-(O
;
White3box3testing3(or3"clear3box3testing")
!"1442&1,8"08(2("*()*)"12("02#**($"B$&0#$+"8&0 *8("*()*(-",&-("0&2B)
C1)(-"&$")*27,*72("1$-"-()#+$"&/",&-(
;
@1$"*()*"#$-#%#-71'",&-("41*8)Q"21$+()"&/"%12#1>'()Q"-1*1"*64() 7)(-"
(*,N
;
M(+N")#**#$+"#$"1",12"08#'(")((#$+"7$-(2"1$-"7$-(2)*1$-#$+"*8(",&34&$($*)"
7$-(2"*8(">&$$(*"1$-"8&0"*8(6"12(",&$$(,*(-O
S()*#$+"levels?
I$#*"AAG"
T$*(+21*#&$"AAG"
96)*(3
S()*#$+"approaches?
C'1,B">&:
H8#*(">&:
Static:3(-->3analysis)
@&-("2(%#(0
H1'B*82&7+8
Dynamic:
@1''#$+"#$-#%"/7$,*$)
9#37'1*#$+"7)(2"#$*N
*Static3analysis
!"1"/&23"&/")*1*#,"*()*#$+"*81*"#$%&'%()"17*&31*#,"1$1'6)#)"&/"*8(",&-("*&"
-(*(23#$("4&))#>'("#))7()
H.F"UIVVTVW"TSN
@&-("2(%#(0"-&$(">6"1",&347*(2"M(+")6$*1:"(22&2)"'#B("3#))#$+"
)(3#,&'&$)O
;
9&3(*#3()",1$")7++()*"42&>'(3)"*81*"12($R*"2(1''6"42&>'(3);
F/*($"4(2/&23(-",&$*#$7&7)'6">6",&-("(-#*&2.TXE"MT$*(+21*(-"
X(%('&43($*"E$%#2&$3($*O
C21,B(*)?"Y9Z#$*
E+N"
var
number = 3;
if
(number = 4)
{
console.log("Is 4");
}
Line 3: Expected a conditional expression and instead
saw an assignment.
;
Coverage3testing
!"27$$#$+"1")4(,#1'"*&&'"*81*"(:(,7*()" 144"31$6"*#3()Q"#-(1''6"7)#$+"
1''"1%1#'1>'("*()*",1)()
H8#'("-&#$+"*8#)Q",&7$*)"8&0"31$6"*#3()"(1,8"'#$("&/")&72,("
,&-("#)"(:(,7*(-
I)71''6"&7*47*)"1$$&*1*(-"%(2"&/")&72,(",&-("0."
(:(,7*#&$",&7$*
E$)72()"*()*",1)()"81%("[\\]",&%(21+("&/",&-(
§
T/"$&*Q
T))7()"#$"7$*()*(-",&-(^
X1$+(2"*81*")&3(&$("3&-#/#()"7$*()*(-"
,&-("1$-"#$*2&-7,()">7+"0.&"$&*#,#$+
^
§
;
_(:*($)#%("17*&31*#,"*()*#$+Q"#$,'7-#$+"*8&7)1$-)"&/"2(+2())#&$"*()*)"/&2"
,&22(,*$())"1$-"4(2/&231$,(O
@81$+#$+")&/*012(",1$"(1)#'6"#$*2&-7,("$(0">7+)"&2",17)("&'-">7+)"*&"
2(144(12
9F"31$6")&/*012("($+"42&`)"2(J",2(1*#&$"&/"**regression3tests3M!"1--#$+"
*()*)"*&"27$"&$",&-("*&",8(,B"#*"0&2B)"42&4(2'6Q"*82&7+8&7*",&$)*27,*#&$"&/"
,&-(O 1)"412*"&/">7+"/#:#$+"42&,())"CODE3SNIPPETS
C7+"#)"#-($*#/#(-"M(+"/23",7)*&3(2"2(4&2*#$+"42&>'(3O[N
F$("($+#$((2"0#''"02#*("*()*",1)(")8&0#$+"42&>'(3"AAG"08#,8"*8($"
/1#')
aN
D2&>'(3"#)"/#:(-"#$")&72,(",&-("
K''"2(+2())#&$"*()*)"27$"M/&2"(1,8"$(0",81$+("*&",&-(">1)(O
@1$",1*,8")#*71*#&$)"08(2("1",81$+("*&"&$(",&34&$($*"
#$-#2(,*'6">2(1B)"1$&*8(2"4#(,("&/",&-(
#N
@1$"/#$-"08(2("1"42(%#&7)'6"&,,722#$+"#))7("2(144(12)##N
1N
F/*($"4(2/&23(-"17*&31*#,1''6"#$"2()4&$)("*&"(%(26",&33#*"*&"
42&`"2(4&
CN
9&3(*#3()",81$+()"12($R*"1''&0(-"*&">(",&33#**(-"7$*#'"*8(6"
41))"1''"*()*)
@N
bN
AAG"41))()
S8("'12+(2" *8(")6)*(3Q"*8("3&2("#$*(21,*#&$)">*0$"-#//",&34&$($*)"&/"
)&72,(",&-(Q"*8("3&2("*8#$+)"+&"02&$+
U(-7,#$+"2#)B"*&"\"#)"$&*"4&))#>'(N
@1$">("42(%($*(-"7)#$+")4(,#/#,"1,,(4*1$,(",2#*(2#1 /&2"7)(2")*&2#()N"M(+N"
21,(,12"1$-"U1,(,12 AAG"4&))#>'(")&'7*#&$"0&7'-">(",81$+#$+"744(2,1)("*&"
'&0(2,1)(">(/&2("*()*#$+O
Levels of3testing
Unit3testing
!")*2())"7$#*)"M)31''"4&2*#&$)O"&/",&-(
W($(21''6"*()*)"/7$,*#&$ M3(*8&-"&/"1",'1))Q"#$",1)("&/"FAFO;
I)71''6"02#**($ >6")&/*012("($+"08#'("#34'(3($*#$+ *81*"4&2*#&$"&/",&-(;
E+?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Unit tests for isPalindrome() function
//
function
TestIsPalindrome()
{
// Public methods (test cases):
this
.oddLengthTest =
function
() {
runTest("racecar",
true
, "oddLengthTest");
};
this
.evenLengthTest =
function
() {
runTest("hannah",
true
, "evenLengthTest");
};
this
.oneCharacterTest =
function
() {
runTest("a",
true
, "oneCharacterTest");
};
this
.caseTest =
function
() {
runTest("Hannah",
true
, "caseTest");
};
this
.emptyStringTest =
function
() {
runTest("",
true
, "emptyStringTest");
};
this
.firstCharacterDifferentTest =
function
() {
runTest("aacecar",
false
,
"firstCharacterDifferentTest");
};
// Iterates over all public methods and calls
each one whose name
// ends in "Test". Saves us having to call
each one individually.
//
this
.runAllTests =
function
() {
for
(
var
methodName
in this
)
{
if
(methodName.endsWith("Test"))
{
var
method =
this
[methodName];
if
(
typeof
method === "function")
{
// Call the test method.
method();
}
}
}
}
// Private methods (support code):
var
runTest =
function
(input, expectedOutput,
testName) {
var
output = isPalindrome(input);
var
passed = expectedOutput === output;
if
(passed)
{
console.log('[PASS] ' + testName);
}
else
{
console.log('[FAIL] ' + testName + ':
isPalindome("' + input + '") !== ' +
expectedOutput);
}
};
}
// Perform the tests.
var
test =
new
TestIsPalindrome();
test.runAllTests()
// Returns true if the given text String is a
palindrome, false otherwise.
//
function
isPalindrome(text)
{
// For every character from beginning to middle
of text,
// compare it to corresponding character at the
end of text.
for
(
var
i = 0; i < (text.length / 2); i++)
{
if
(text[i] != text[text.length -1 -i])
{
// Character pair doesn't match, not a
palindrome.
return false
;
}
}
// All character pairs matched, is a
palindrome.
return true
;
}
ccS&"*()*"1",'1))"#$)*(1-"&/"1"/7$,*#&$Q",2(1*("1")#3#'12"*()*",'1))N
E1,8"*()*",1)("3(*8&-"#$"*8("*()*",'1))"0&7'-?
@2(1*(",'1))"#$)*1$,("&/",'1))"*&">("*()*(-;
@1''"!G["3(*8&-)"&$"*81*"#$)*1$,("*&",81$+("#*)")*1*(;
@1''")&3("&*8(2"3(*8&-)"*&",8(,B"*8(")*1*("&/"*8(",'1))"#$)*1$,("1$-"
,&3412("*&"(:4(,*(-"&7*,&3(
;
Integration3testing
!"(:13#$(">(81%#&72"1$-",&33 >*0$"!Ga")6)*(3",&34&$($*)
@8(,B)">(81%#&72"&/",&34&$($*)"1+1#$)*"-&,73($*1*#&$ M7)71''6"81%("
0(''A-(/"#$*(2/1,()O
@&34&$($*)"!"*0&",'1))()"7)(-"*+*d"1",'1))"*81*",&33)"0#*8"1"0(>"
)(2%#,(
;
S12+(*)">7+) *81*",&7'-"(3(2+("08($"M)7>O)6)*(3) _*81*"0&2B"4(2/(,*'6"
#$"#)&'1*#&$e",&&4(21*( 0#*8"(1,8"&*8(2
;
M(+N"-1*1"'16(2"&/"1"3&>#'("144"*81*",&337$#,1*()"0."S0#**(2"1$-")*&2()"*8("
'&,1'"%(2"&/"1")(*"&/"#$/&"/23"S0#**(2"0(>)#*(
AAG",2(1*(",&-("*81*"2(*72$)")134'("-1*1"#$"*8(")13("/&231*"1)"S0#**(2"
0(>")(2%#,(O
@122#(-"&7*"K=SEU"7$#*"*()*#$+"#)")7,,())/7';
System3testing
!"*()*#$+"*8(",&34'(*( 144'#,1*#&$"#$"&2-(2"*&",8(,B"*81*"#*")1*#)/#()"#*)"2(J)
S()*)",2(1*(-"/2&3"7)(2")*&2#()"FU"1,*#%#*6"-#1+213)",2(1*(-"-72#$+"
-()#+$
@8(,B"/&2",&22(,*">(81%#&72
@8(,B"/&2"7$01$*(-">(81%#&72"(+N",21)8#$+Q"'&)#$+"7)(2"-1*1
;
Week$9:$Software$Verification
=2#-16Q"af"K42#'"a\[g [h?[a
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 7 pages and 3 million more documents.

Already have an account? Log in

Document Summary

= involves testing code/software components to find errors/defects. Complicated - many different possible eventualities that take into consideration/cope with all the ways a user interacts with it and the data they input. Software apps are complex systems of interacting components passing messages and information between each other. Bugs in one component can easily manifest as subtle problems in another. Problems in software hard to track down and correct. Often modified --> easily lead to new bugs. Static testing = approaches that test the code/application w/o running it. Code review = looking through code visually and searching. Walkthrough = following a process and looking for problem cases. Using source code or technical document describing process in question. Dynamic testing = approaches that perform tests on running code. Calling individual functions with specific input and checking return values. Aka specifying random inputs and looking for errors/crashes.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers