forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEvalDiv.test
More file actions
83 lines (57 loc) · 1.16 KB
/
Copy pathEvalDiv.test
File metadata and controls
83 lines (57 loc) · 1.16 KB
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
setup "number div number"
test (7 div 3) is 2
test (8 div 3) is 2
test (9 div 3) is 3
test (-7 div 3) is -2
test (-8 div 3) is -2
test (-9 div 3) is -3
test (7 div -3) is -2
test (8 div -3) is -2
test (9 div -3) is -3
test (-7 div -3) is 2
test (-8 div -3) is 2
test (-9 div -3) is 3
teardown
setup "array div number"
local tA1, tA2
repeat with i = 1 to 10
put i into tA1[i]
end repeat
put tA1 div 3 into tA2
repeat with i = 1 to 10
test tA2[i] is (tA1[i] div 3)
end repeat
// empty array entry is 0
put empty into tA1
put empty into tA1[0]
put tA1 div 3 into tA2
test tA2[0] is 0
teardown
setup "array div array"
local tA1, tA2, tA3
repeat with i = 1 to 10
put i into tA1[i]
put (11 - i) into tA2[i]
end repeat
put tA1 div tA2 into tA3
repeat with i = 1 to 10
test tA3[i] is (tA1[i] div tA2[i])
end repeat
teardown
setup "div errors"
local tA1, tA2
// div by zero
test-error 5 div 0
put 5 into tA1[0]
put 0 into tA2[0]
test-error tA1 div 0
test-error tA1 div tA2
// missing array entries
put 6 into tA1[1]
put 1 into tA2[0]
test-error tA1 div tA2
// non-number array entries
put "abc" into tA2[1]
test-error tA1 div tA2
test-error tA2 div tA1
teardown