forked from decaffeinate/decaffeinate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
return_test.js
58 lines (52 loc) · 1.03 KB
/
return_test.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
import check from './support/check.js';
describe('return', () => {
it('works with a return value', () =>
check(`
-> a; return 1
`, `
(function() { a; return 1; });
`)
);
it('works without a return value', () =>
check(`
->
return if a
`, `
(function() {
if (a) { return; }
});
`)
);
it('forces the return value to be an expression', () =>
check(`
-> return if true then null
`, `
() => true ? null : undefined;
`)
);
it('preserves comments when removing trailing empty returns', () =>
check(`
->
a # b
return
`, `
(function() {
a; // b
});
`)
);
it('correctly removes trailing empty returns on the same line as another statement', () =>
check(`
-> a; return
`, `
(function() { a; });
`)
);
it('correctly removes trailing empty returns as the only function statement', () =>
check(`
-> return
`, `
(function() { });
`)
);
});