-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcases.py
62 lines (56 loc) · 818 Bytes
/
testcases.py
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
case_while = '''
var n = 5;
var p = 1;
while(n > 0)
{
p = p * n;
n = n - 1;
}
log(p, n);
'''
case_function = '''
var inc = function(a) {
return a + 1;
};
log(inc(1));
'''
case_if = '''
if (true)
{
log(1);
}
else
{
log(2);
}
'''
case_recursion = '''
var fac = function(n) {
if (n <= 1)
{
return 1;
}
return n * fac(n - 1);
};
log(fac(6));
'''
case_Y = '''
var Y = function (F) {
return (function (x) {
return F(function (y) { return (x(x))(y);});
})
(function (x) {
return F(function (y) { return (x(x))(y);});
});
};
var FactGen = function (fact) {
return (function(n) {
if (n == 0) {
return 1;
} else {
return n * fact(n - 1);
}
});
};
log((Y(FactGen))(7));
'''