Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: test/expression_test.ts

Issue 2225953002: Strip more unused features. (Closed) Base URL: git@github.com:dart-lang/js_facade_gen.git@master
Patch Set: Fix types Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/e2e/pubspec.yaml ('k') | test/facade_converter_test.ts » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/expression_test.ts
diff --git a/test/expression_test.ts b/test/expression_test.ts
index 85eec7b7fa9709fed758c411b1147e225de1c17f..64302ff3d91fe79f821c70101ed8dd253aa7dda2 100644
--- a/test/expression_test.ts
+++ b/test/expression_test.ts
@@ -1,97 +1,88 @@
/// <reference path="../typings/mocha/mocha.d.ts"/>
-import {expectTranslate, expectErroneousCode} from './test_support';
+import {expectTranslate} from './test_support';
-function expectTranslates(cases: any) {
- for (let tsCode of Object.keys(cases)) {
- expectTranslate(tsCode).to.equal(cases[tsCode]);
+function expectEmptyTranslates(cases: string[]) {
+ for (let tsCode of cases) {
+ expectTranslate(tsCode).to.equal('');
}
}
// TODO(jacobr): we don't really need to be specifying separate code for the
// JS and Dart version for these tests as the code formatting is identical.
-describe('expressions', () => {
- it('does math', () => {
- expectTranslates({
- '1 + 2': '1 + 2;',
- '1 - 2': '1 - 2;',
- '1 * 2': '1 * 2;',
- '1 / 2': '1 / 2;',
- '1 % 2': '1 % 2;',
- 'x++': 'x++;',
- 'x--': 'x--;',
- '++x': '++x;',
- '--x': '--x;',
- '-x': '-x;',
- });
+describe('ignore expressions', () => {
+ it('math', () => {
+ expectEmptyTranslates([
+ '1 + 2',
+ '1 - 2',
+ '1 * 2',
+ '1 / 2',
+ '1 % 2',
+ 'x++',
+ 'x--',
+ '++x',
+ '--x',
+ '-x',
+ ]);
});
it('assigns', () => {
- expectTranslates({
- 'x += 1': 'x += 1;',
- 'x -= 1': 'x -= 1;',
- 'x *= 1': 'x *= 1;',
- 'x /= 1': 'x /= 1;',
- 'x %= 1': 'x %= 1;',
- 'x <<= 1': 'x = (x as int) << 1;',
- 'x >>= 1': 'x = (x as int) >> 1;',
- // 'x >>>= 1': 'x >>>= 1;', // This doesn't appear to be a valid operator in Dart.
- 'x &= 1': 'x = (x as int) & 1;',
- 'x ^= 1': 'x = (x as int) ^ 1;',
- 'x |= 1': 'x = (x as int) | 1;',
- });
+ expectEmptyTranslates([
+ 'x += 1',
+ 'x -= 1',
+ 'x *= 1',
+ 'x /= 1',
+ 'x %= 1',
+ 'x <<= 1',
+ 'x >>= 1',
+ 'x >>>= 1',
+ 'x &= 1',
+ 'x ^= 1',
+ 'x |= 1',
+ ]);
});
it('compares', () => {
- expectTranslates({
- '1 == 2': '1 == 2;',
- '1 != 2': '1 != 2;',
- '1 > 2': '1 > 2;',
- '1 < 2': '1 < 2;',
- '1 >= 2': '1 >= 2;',
- '1 <= 2': '1 <= 2;',
- });
- });
- it('compares identity', () => {
- expectTranslate('1 === 2').to.equal('identical(1, 2);');
- expectTranslate('1 !== 2').to.equal('!identical(1, 2);');
+ expectEmptyTranslates([
+ '1 == 2',
+ '1 != 2',
+ '1 > 2',
+ '1 < 2',
+ '1 >= 2',
+ '1 <= 2',
+ ]);
});
+ it('compares identity', () => { expectEmptyTranslates(['1 === 2', '1 !== 2']); });
it('bit fiddles', () => {
- expectTranslates({
- 'x & 2': '(x as int) & 2;',
- '1 & 2': '1 & 2;',
- '1 | 2': '1 | 2;',
- '1 ^ 2': '1 ^ 2;',
- '~1': '~1;',
- '1 << 2': '1 << 2;',
- '1 >> 2': '1 >> 2;',
- '0x1 & 0x2': '0x1 & 0x2;',
- // '1 >>> 2': '1 >>> 2;', // This doesn't appear to be a valid operator in Dart.
- });
+ expectEmptyTranslates(
+ ['x & 2', '1 & 2', '1 | 2', '1 ^ 2', '~1', '1 << 2', '1 >> 2', '0x1 & 0x2', '1 >>> 2']);
});
it('translates logic', () => {
- expectTranslates({
- '1 && 2': '1 && 2;',
- '1 || 2': '1 || 2;',
- '!1': '!1;',
- });
+ expectEmptyTranslates([
+ '1 && 2',
+ '1 || 2',
+ '!1',
+ ]);
+ });
+ it('translates ternary', () => {
+ expectTranslate('var x = 1 ? 2 : 3').to.equal(`@JS()
+external get x;
+@JS()
+external set x(v);`);
+ });
+ it('translates the comma operator', () => {
+ expectTranslate('var x = [1, 2]').to.equal(`@JS()
+external get x;
+@JS()
+external set x(v);`);
});
- it('translates ternary',
- () => { expectTranslate('var x = 1 ? 2 : 3').to.equal('var x = 1 ? 2 : 3;'); });
- it('translates the comma operator',
- () => { expectTranslate('var x = [1, 2]').to.equal('var x = [1, 2];'); });
- it('translates "in"',
- () => { expectErroneousCode('x in y').to.throw('in operator is unsupported'); });
- it('translates "instanceof"',
- () => { expectTranslate('1 instanceof Foo').to.equal('1 is Foo;'); });
- it('translates "this"', () => { expectTranslate('this.x').to.equal('this.x;'); });
- it('translates "delete"',
- () => { expectErroneousCode('delete x[y];').to.throw('delete operator is unsupported'); });
- it('translates "typeof"',
- () => { expectErroneousCode('typeof x;').to.throw('typeof operator is unsupported'); });
- it('translates "void"',
- () => { expectErroneousCode('void x;').to.throw('void operator is unsupported'); });
- it('translates parens', () => { expectTranslate('(1)').to.equal('(1);'); });
+ it('translates "in"', () => { expectTranslate('x in y').to.equal(''); });
+ it('translates "instanceof"', () => { expectTranslate('1 instanceof Foo').to.equal(''); });
+ it('translates "this"', () => { expectTranslate('this.x').to.equal(''); });
+ it('translates "delete"', () => { expectTranslate('delete x[y];').to.equal(''); });
+ it('translates "typeof"', () => { expectTranslate('typeof x;').to.equal(''); });
+ it('translates "void"', () => { expectTranslate('void x;').to.equal(''); });
+ it('translates parens', () => { expectTranslate('(1)').to.equal(''); });
it('translates property paths', () => {
- expectTranslate('foo.bar;').to.equal('foo.bar;');
- expectTranslate('foo[bar];').to.equal('foo[bar];');
+ expectTranslate('foo.bar;').to.equal('');
+ expectTranslate('foo[bar];').to.equal('');
});
});
« no previous file with comments | « test/e2e/pubspec.yaml ('k') | test/facade_converter_test.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698