-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-different.html
executable file
·141 lines (126 loc) · 3 KB
/
example-different.html
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<script src="jfUnit/jfUnit.js"></script>
<body>
</body>
<script>
// functions to test
function sum(value1, value2)
{
return value1+value2;
}
function division(value1, value2)
{
return value2>0? value1/value2: 0;
}
function createElement(){
var spn= document.createElement('span');
spn.style.border= 'solid 1px red';
spn.innerHTML= "Div created dinamicaly";
document.getElementsByTagName('body')[0].appendChild(spn);
return true;
}
// the tests
// they actually go into your library, if you want to
// assertIn
// simple mode
jfUnit.assertIn(sum, 10, 0, [9,10,11]); // ok
jfUnit.assertIn(sum, 10, 0, [9,12,11]); // error
// advanced mode
jfUnit.assertIn({
call:sum,
v1:10,
v2:2,
expected:[10, 12]
}); // ok
jfUnit.assertIn({
call:sum,
v1:10,
v2:2,
expected:[10, 11, 13]
}); // error
// assertNotIn
// simple mode
jfUnit.assertNotIn(sum, 10, 0, [9,12,11]); // ok
jfUnit.assertNotIn(sum, 10, 0, [9,10,11]); // error
// advanced mode
jfUnit.assertNotIn({
call:sum,
v1:10,
v2:2,
expected:[10, 11, 13]
}); // ok
jfUnit.assertNotIn({
call:sum,
v1:10,
v2:2,
expected:[10, 12]
}); // error
// assertNot
// simple mode
jfUnit.assertNot(sum, 10, 0, 0); // ok
jfUnit.assertNot(sum, 10, 0, 10); // error
// advanced mode
jfUnit.assertNot({
call:sum,
v1:10,
v2:2,
expected: 10
}); // ok
jfUnit.assertNot({
call:sum,
v1:10,
v2:2,
expected: 12
}); // error
// assertBetween
// simple mode
jfUnit.assertBetween(sum, 10, 0, [9,11]); // ok
jfUnit.assertBetween(sum, 10, 0, [7,9]); // error
// advanced mode
jfUnit.assertBetween({
call:sum,
v1:10,
v2:2,
expected: [5, 16]
}); // ok
jfUnit.assertBetween({
call:sum,
v1:10,
v2:2,
expected: [4,9]
}); // error
// assertNotBetween
// simple mode
jfUnit.assertNotBetween(sum, 10, 0, [7,9]); // ok
jfUnit.assertNotBetween(sum, 10, 0, [9,11]); // error
// advanced mode
jfUnit.assertNotBetween({
call:sum,
v1:10,
v2:2,
expected: [4, 9]
}); // ok
jfUnit.assertNotBetween({
call:sum,
v1:10,
v2:2,
expected: [5,16]
}); // error
jfUnit.assertGT(sum, 10, 2, 3); // ok
jfUnit.assertGT(sum, 10, 2, 16); // fail
jfUnit.assertLT(sum, 10, 2, 16); // ok
jfUnit.assertLT(sum, 10, 2, 3); // fail
jfUnit.assertType(sum, 10, 2, 'integer'); // ok
jfUnit.assertType(sum, 10, 'a', 'integer'); // fail
jfUnit.assertType(division, 10, 3, 'real'); // ok
jfUnit.assertType(division, 10, 3, 'integer'); // fail
// let's assert that that function works in the end
jfUnit.assert(createElement, true);
// jfUnit.assertState(document.getElementById('someId'), true);
// now, let's run it here
// though, you may call this method from your console, anytime, once
// your tests are already loaded rom all the libs
//
// simply comment this line to not perform the tests
// you' application will run just fine
jfUnit.run();
</script>