OLD | NEW |
1 /// <reference path="../typings/mocha/mocha.d.ts"/> | 1 /// <reference path="../typings/mocha/mocha.d.ts"/> |
2 import {expectTranslate} from './test_support'; | 2 import {expectTranslate} from './test_support'; |
3 | 3 |
4 function expectEmptyTranslates(cases: string[]) { | 4 function expectEmptyTranslates(cases: string[]) { |
5 for (let tsCode of cases) { | 5 for (let tsCode of cases) { |
6 expectTranslate(tsCode).to.equal(''); | 6 expectTranslate(tsCode).to.equal(''); |
7 } | 7 } |
8 } | 8 } |
9 | 9 |
10 // TODO(jacobr): we don't really need to be specifying separate code for the | 10 // TODO(jacobr): we don't really need to be specifying separate code for the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 it('compares', () => { | 42 it('compares', () => { |
43 expectEmptyTranslates([ | 43 expectEmptyTranslates([ |
44 '1 == 2', | 44 '1 == 2', |
45 '1 != 2', | 45 '1 != 2', |
46 '1 > 2', | 46 '1 > 2', |
47 '1 < 2', | 47 '1 < 2', |
48 '1 >= 2', | 48 '1 >= 2', |
49 '1 <= 2', | 49 '1 <= 2', |
50 ]); | 50 ]); |
51 }); | 51 }); |
52 it('compares identity', () => { expectEmptyTranslates(['1 === 2', '1 !== 2']);
}); | 52 it('compares identity', () => { |
| 53 expectEmptyTranslates(['1 === 2', '1 !== 2']); |
| 54 }); |
53 it('bit fiddles', () => { | 55 it('bit fiddles', () => { |
54 expectEmptyTranslates( | 56 expectEmptyTranslates( |
55 ['x & 2', '1 & 2', '1 | 2', '1 ^ 2', '~1', '1 << 2', '1 >> 2', '0x1 & 0x
2', '1 >>> 2']); | 57 ['x & 2', '1 & 2', '1 | 2', '1 ^ 2', '~1', '1 << 2', '1 >> 2', '0x1 & 0x
2', '1 >>> 2']); |
56 }); | 58 }); |
57 it('translates logic', () => { | 59 it('translates logic', () => { |
58 expectEmptyTranslates([ | 60 expectEmptyTranslates([ |
59 '1 && 2', | 61 '1 && 2', |
60 '1 || 2', | 62 '1 || 2', |
61 '!1', | 63 '!1', |
62 ]); | 64 ]); |
63 }); | 65 }); |
64 it('translates ternary', () => { | 66 it('translates ternary', () => { |
65 expectTranslate('var x = 1 ? 2 : 3').to.equal(`@JS() | 67 expectTranslate('var x = 1 ? 2 : 3').to.equal(`@JS() |
66 external get x; | 68 external get x; |
67 @JS() | 69 @JS() |
68 external set x(v);`); | 70 external set x(v);`); |
69 }); | 71 }); |
70 it('translates the comma operator', () => { | 72 it('translates the comma operator', () => { |
71 expectTranslate('var x = [1, 2]').to.equal(`@JS() | 73 expectTranslate('var x = [1, 2]').to.equal(`@JS() |
72 external get x; | 74 external get x; |
73 @JS() | 75 @JS() |
74 external set x(v);`); | 76 external set x(v);`); |
75 }); | 77 }); |
76 it('translates "in"', () => { expectTranslate('x in y').to.equal(''); }); | 78 it('translates "in"', () => { |
77 it('translates "instanceof"', () => { expectTranslate('1 instanceof Foo').to.e
qual(''); }); | 79 expectTranslate('x in y').to.equal(''); |
78 it('translates "this"', () => { expectTranslate('this.x').to.equal(''); }); | 80 }); |
79 it('translates "delete"', () => { expectTranslate('delete x[y];').to.equal('')
; }); | 81 it('translates "instanceof"', () => { |
80 it('translates "typeof"', () => { expectTranslate('typeof x;').to.equal(''); }
); | 82 expectTranslate('1 instanceof Foo').to.equal(''); |
81 it('translates "void"', () => { expectTranslate('void x;').to.equal(''); }); | 83 }); |
82 it('translates parens', () => { expectTranslate('(1)').to.equal(''); }); | 84 it('translates "this"', () => { |
| 85 expectTranslate('this.x').to.equal(''); |
| 86 }); |
| 87 it('translates "delete"', () => { |
| 88 expectTranslate('delete x[y];').to.equal(''); |
| 89 }); |
| 90 it('translates "typeof"', () => { |
| 91 expectTranslate('typeof x;').to.equal(''); |
| 92 }); |
| 93 it('translates "void"', () => { |
| 94 expectTranslate('void x;').to.equal(''); |
| 95 }); |
| 96 it('translates parens', () => { |
| 97 expectTranslate('(1)').to.equal(''); |
| 98 }); |
83 | 99 |
84 it('translates property paths', () => { | 100 it('translates property paths', () => { |
85 expectTranslate('foo.bar;').to.equal(''); | 101 expectTranslate('foo.bar;').to.equal(''); |
86 expectTranslate('foo[bar];').to.equal(''); | 102 expectTranslate('foo[bar];').to.equal(''); |
87 }); | 103 }); |
88 }); | 104 }); |
OLD | NEW |