-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlangtest.tl
103 lines (78 loc) · 1.3 KB
/
langtest.tl
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
# this is a comment
_PRINTVARTABLE()
assertEquals(0, 0)
assert(0 = 0)
assertEquals(0 = 0, true)
assertEquals(0 = 1, false)
assert(not (0 <> 0))
assert(0 <> 1)
assert(1 > 0)
assert(-1 < 0)
assert(0 = 0.0)
assertEquals(0 + 1, 1)
assertEquals(1 + 1, 2)
assertEquals(0 - 1, -1)
assertEquals(2 - 1, 1)
assertEquals(30 - 40, -10)
assertEquals(0.0 + 1, 1.0)
assertEquals(1 + 1.0, 2.0)
assertEquals(0.0 - 1.0, -1.0)
assertEquals(2 - 1.0, 1.0)
assertEquals(30.0 - 40, -10.0)
var a: int = 50
assertEquals(a, 50)
var b: int
b:= -30
assertEquals(b, -30)
assertEquals(a + b, 20)
a:= 10
b:= 5
assertEquals(a / b, 2)
a:= 1
b:= 3
assertEquals(a / b, 0)
var c: float = 1.0
var d: float = 3.0
assertEquals(c / d, 0.33333334)
assertEquals(3 * 10 / 3 , 10)
assertEquals(5 > 6, false)
assertEquals(5 >= 5, true)
assertEquals(5 <= 6, true)
assertEquals(5 * 2 + 3, 13)
assertEquals(5 * (2 + 3), 25)
_PRINTVARTABLE()
a := 0
b := 5
while (a <= 5) {
a:= a + 1
b:= b - 1
}
_PRINTLINEINFO()
assertEquals(a , 6)
assertEquals(b, -1)
if true {
a:= 1
}
assertEquals(a, 1)
if false {
a:= 0
}
assertEquals(a, 1)
assertEquals(a, 5)
fun f(): int {
a:= 5
return a + 1
}
b:= f()
assertEquals(a, 5)
assertEquals(b, 6)
#fun f1(): int {
# a:= 5
# return a
#}
#bug here
#f1()
{}
#a:= readInt()
writeLn(a)
_PRINTVARTABLE()