forked from codecombat/codecombat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatement_count_spec.js
100 lines (93 loc) · 1.75 KB
/
statement_count_spec.js
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
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
const Aether = require('../aether');
const cs = (desc, lang, count, code) => it(`${lang}: ${desc}`, function() {
const aether = new Aether({
language: lang});
aether.transpile(code);
return expect(aether.getStatementCount()).toEqual(count);
});
describe("Statement Counting", function() {
describe("Python", function() {
cs("Simple", "python", 3, `\
one()
two()
three()\
`
);
cs("Mathy", "python", 2, `\
if self.a() > something.b and self.c():
x = somethingElse()\
`
);
cs("while loop", "python", 3, `\
while True:
self.moveLeft();
self.moveRight();\
`
);
cs("for sum", "python", 3, `\
for i in xrange(1,10):
self.say(i) \
`
);
return cs("function", "python", 3, `\
def x(a):
return a+2
x(2)\
`
);
});
describe("Javascript", function() {
cs("Simple", "javascript", 3, `\
one();
two();
three();\
`
);
cs("Mathy", "javascript", 2, `\
if ( this.a() > something.b && this.c() )
var x = somethingElse();\
`
);
cs("while loop", "javascript", 3, `\
while ( true ) {
self.moveLeft();
self.moveRight();
}\
`
);
cs("for sum", "javascript", 3, `\
for ( var i = 0; i < 10; ++i ) this.say(i);\
`
);
return cs("function", "javascript", 3, `\
function x(a) {
return x + 2;
}
x(2);\
`
);
});
return describe("Lua", function() {
cs("Simple", "lua", 3, `\
one()
two()
three()\
`
);
cs("Mathy", "lua", 2, `\
if (self:a() > something.b) and self.c() then
x = somethingElse()
end\
`
);
return cs("for sum", "lua", 2, `\
for i = 1,10 do this.say(i) end\
`
);
});
});