-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.fss
126 lines (114 loc) · 2.07 KB
/
test.fss
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
#Test comment
print2(abc, def):
print(abc)
print(def)
return 0
iftest1():
if true:
print(0)
if false:
print(1)
return 1
iftest2():
if false:
print("2")
elif true:
print("0")
else:
print("1")
return 2
scopetest():
let x = 0
let y = 1
let cond = true
if true:
let x = 2
y = 3
print2(x - 2, y - 3)
print2(x, y - 3)
return 0
parenstest():
return ((0))
optest():
x = 3 - -4 - 5 * -(2 + 6 / 5)
let y = -22
return x + y
comptest():
let x = 1
let y = 2
if x > y:
return -1
if y + 1 < x + 1:
x = x + 1
if y * 2 != x * 2:
return -1
else:
if y <= x:
y = y - 1
if y >= x:
return -1
return 0
booltest():
let x = 3
if !(1 > 2 & 2 > 1):
x = x - 1
if (1 > 2 | 2 > 1):
x = x - 1
x = x - 1
return x
isprime(n):
if n < 2:
return false
for i in range(2, sqrt(n) + 1):
if n % i == 0:
return false
return true
primetest():
if isprime(1):
print(1)
if !isprime(2):
print(1)
if !isprime(3):
print(1)
if isprime(4):
print(1)
if isprime(5 * 6):
print(1)
if !isprime(37):
print(1)
if isprime(91):
print(1)
if isprime(1001):
print(1)
if !isprime(1009):
print(1)
return 0
fib(i):
if i <= 0:
return 0
elif i == 1:
return 1
return fib(i - 1) + fib(i - 2)
fibtest():
let a = fib(7) - 12
a *= fib(8) - 20
a *= fib(0) + 1
a *= fib(10) - 54
a *= fib(a)
return a - 1
main():
let str = "Hello, world!"
let str2 = "F# is the best!"
print2(str, str2)
print("The following outputs should print \"0\":")
print(iftest1() - 1)
iftest2()
scopetest()
print(parenstest())
print(optest())
print(comptest())
print(booltest())
print(primetest())
print(fibtest())
print("done.")
return 0