Permalink
Browse files

Update feature tests to es6.

Mostly this is porting to es6 and fixups.

Some files no longer used by feature tests
are still used by a few node tests.

Tested in the browser as well.

Review URL: https://api.github.com/repos/google/traceur-compiler/issues/1959

Closes #1959.
  • Loading branch information...
1 parent b07ba6d commit 5ac6675c29f47a51b7dc6b92b1809517f62c33c7 @johnjbarton johnjbarton committed Jun 22, 2015
Showing with 494 additions and 506 deletions.
  1. +9 −11 Makefile
  2. +0 −58 build/build-test-list.js
  3. +1 −1 src/runtime/LoaderCompiler.js
  4. +1 −0 test/feature/Destructuring/Simplify.js
  5. +4 −4 test/feature/MemberVariables/Assertions.module.js
  6. +3 −2 test/feature/MemberVariables/ClassExpression.module.js
  7. +5 −4 test/feature/MemberVariables/Inheritance.module.js
  8. +2 −1 test/feature/MemberVariables/NestedClass.module.js
  9. +1 −1 test/feature/Modules/Error_InvalidModuleDeclaration.module.js
  10. +3 −1 test/feature/Modules/ModuleName.module.js
  11. +2 −2 test/feature/ObjectInitializerShorthand/Error_StrictKeyword.js
  12. +1 −1 test/feature/Syntax/Error_StrictKeywordsInArguments.js
  13. +8 −6 test/feature/TypeAssertions/ClassParams.module.js
  14. +4 −2 test/feature/TypeAssertions/ClassReturnTypes.module.js
  15. +4 −1 test/feature/TypeAssertions/DefaultParam.module.js
  16. +3 −2 test/feature/TypeAssertions/ExportedFunction.module.js
  17. +7 −5 test/feature/TypeAssertions/FunctionParams.module.js
  18. +4 −1 test/feature/TypeAssertions/FunctionReturnType.module.js
  19. +5 −3 test/feature/TypeAssertions/NestedFunctionDefaultParam.module.js
  20. +4 −3 test/feature/TypeAssertions/PrimitiveValueTypes.module.js
  21. +3 −1 test/feature/TypeAssertions/Variables.module.js
  22. +1 −1 test/feature/TypeAssertions/resources/assert.js
  23. +349 −0 test/featureTestRunner.js
  24. +19 −9 test/modular/BrowserTraceurTestRunner.js
  25. +7 −4 test/modular/Mocha6.js
  26. +1 −1 test/modular/NodeTraceurTestRunner.js
  27. +1 −13 test/modular/TraceurTestRunner.js
  28. +1 −0 test/node-amd-test.js
  29. +1 −0 test/node-api-test.js
  30. +0 −28 test/node-feature-test.js
  31. +16 −7 test/node-instantiate-test.js
  32. +8 −4 test/{node-env.js → runFeatureTests.js}
  33. +0 −1 test/runtime.html
  34. +0 −322 test/test-utils.js
  35. +16 −6 testRunner.html
View
@@ -59,17 +59,19 @@ UNIT_TESTS = \
test/unit/runtime \
#END UNIT_TESTS
+FEATURE_TESTS = \
+ test/feature/*/*.js
+
TESTS = \
test/node-commonjs-test.js \
test/node-amd-test.js \
test/node-closure-test.js \
test/node-instantiate-test.js \
- test/node-feature-test.js \
test/node-api-test.js \
# End Node tests.
MOCHA_OPTIONS = \
- --ignore-leaks --ui tdd --reporter dot --require test/node-env.js
+ --ignore-leaks --ui tdd --reporter dot
ifdef ONLY
MOCHA_OPTIONS := $(MOCHA_OPTIONS) --grep $(ONLY)
@@ -90,19 +92,23 @@ ugly: bin/traceur.ugly.js
test-runtime: bin/traceur-runtime.js $(RUNTIME_TESTS)
@echo 'Open test/runtime.html to test runtime only'
-test: test/test-list.js bin/traceur.js \
+test: bin/traceur.js \
test/unit \
test/unit/runtime/traceur-runtime \
wiki test/amd-compiled test/commonjs-compiled test-interpret \
test-interpret-absolute test-inline-module-error \
test-version \
+ test/features \
test-experimental
node_modules/.bin/mocha $(MOCHA_OPTIONS) $(TESTS)
$(MAKE) test-interpret-throw
test/unit: bin/traceur.js bin/traceur-runtime.js $(UNIT_TESTS)
./tval test/runUnitTests.js
+test/features: bin/traceur.js bin/traceur-runtime.js $(FEATURE_TESTS)
+ ./tval test/runFeatureTests.js
+
test/%-run: test/% bin/traceur.js
node_modules/.bin/mocha $(MOCHA_OPTIONS) $<
@@ -115,14 +121,6 @@ test/amd: test/amd-compiled
test/closure:
node_modules/.bin/mocha $(MOCHA_OPTIONS) test/node-closure-test.js
-test/features: bin/traceur.js bin/traceur-runtime.js test/test-list.js
- node_modules/.bin/mocha $(MOCHA_OPTIONS) $(MOCHAX) test/node-feature-test.js
-
-test-list: test/test-list.js
-
-test/test-list.js: force
- @git ls-files -o -c test/feature | node build/build-test-list.js > $@
-
test-interpret: test/unit/node/traceur-interpreter.js
./traceur $^
@@ -1,58 +0,0 @@
-// Copyright 2013 Traceur Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-'use strict';
-
-var fs = require('fs');
-
-/**
- * Returns all input read from |fd| as a string, correctly handling ending of
- * piped input.
- * @param {number} fd File descriptor to read from.
- * @return {string}
- */
-function readSyncString(fd) {
- var BUFFER_SIZE = 4096;
-
- var buf = new Buffer(BUFFER_SIZE);
- var len = 0;
- var text = '';
-
- try {
- while (len = fs.readSync(fd, buf, 0, BUFFER_SIZE, null)) {
- text += buf.toString('utf8', 0, len);
- }
- } catch (e) {
- // On Windows readSync throws if attempting to read at EOF
- if (e.message.indexOf('EOF') != 0) {
- throw e;
- }
- }
- return text;
-}
-
-var lines = readSyncString(process.stdin.fd).split('\n').filter(function(x) {
- // Remove /resources/ directories.
- if (/\/resources\//i.test(x))
- return false;
-
- // JS files only
- return x && x.match('\\.js$');
-}).map(function(x) {
- // remove "test/feature/"
- return x.split('/').slice(2).join('/');
-});
-
-console.log('var testList = %s;', JSON.stringify(lines, null, 2));
-console.log('if (typeof exports === \'object\') exports.testList = testList;');
@@ -62,7 +62,7 @@ export class LoaderCompiler {
metadata.compiler = new Compiler(options);
- // The name used in sourceMaps
+ // The name used in sourceMaps and error messages
var sourceName = codeUnit.metadata.sourceName = codeUnit.address ||
codeUnit.normalizedName || '(unnamed)#' + String(++anonymousSourcesSeen);
metadata.tree = metadata.compiler.parse(codeUnit.source, sourceName);
@@ -7,6 +7,7 @@
'use strict';
var a, b, c, x, y, z;
+a = b = c = x = y = z = undefined;
// ----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
// Options: --member-variables --types --type-assertions --type-assertion-module=../TypeAssertions/resources/assert.js
-
+import {AssertionError} from '../../asserts.js';
import '../TypeAssertions/resources/assert.js';
class Test {
@@ -20,6 +20,6 @@ assert.equal(test.a, 'a');
Test.b = 'b';
assert.equal(Test.b, 'b');
-assert.throw(() => { test.uninitialized; }, chai.AssertionError);
-assert.throw(() => { test.a = 0; }, chai.AssertionError);
-assert.throw(() => { Test.b = 0; }, chai.AssertionError);
+assert.throw(() => { test.uninitialized; }, AssertionError);
+assert.throw(() => { test.a = 0; }, AssertionError);
+assert.throw(() => { Test.b = 0; }, AssertionError);
@@ -1,5 +1,6 @@
// Options: --member-variables --types --type-assertions --type-assertion-module=../TypeAssertions/resources/assert.js
+import {AssertionError} from '../../asserts.js';
import '../TypeAssertions/resources/assert.js';
class C extends class {
@@ -10,5 +11,5 @@ class C extends class {
var c = new C();
-assert.throw(() => { c.x = 'str'}, chai.AssertionError);
-assert.throw(() => { c.y = 'str'}, chai.AssertionError);
+assert.throw(() => { c.x = 'str'}, AssertionError);
+assert.throw(() => { c.y = 'str'}, AssertionError);
@@ -1,5 +1,6 @@
// Options: --member-variables --types --type-assertions --type-assertion-module=../TypeAssertions/resources/assert.js
+import {AssertionError} from '../../asserts.js';
import '../TypeAssertions/resources/assert.js';
class Parent {
@@ -18,7 +19,7 @@ child.b = 'defined in Child';
Child.staticA = 'static in Parent';
Child.staticB = 'static in Child';
-assert.throw(() => { child.a = 0; }, chai.AssertionError);
-assert.throw(() => { child.b = 0; }, chai.AssertionError);
-assert.throw(() => { Child.staticA = 0; }, chai.AssertionError);
-assert.throw(() => { Child.staticB = 0; }, chai.AssertionError);
+assert.throw(() => { child.a = 0; }, AssertionError);
+assert.throw(() => { child.b = 0; }, AssertionError);
+assert.throw(() => { Child.staticA = 0; }, AssertionError);
+assert.throw(() => { Child.staticB = 0; }, AssertionError);
@@ -1,5 +1,6 @@
// Options: --member-variables --types --type-assertions --type-assertion-module=../TypeAssertions/resources/assert.js
+import {AssertionError} from '../../asserts.js';
import '../TypeAssertions/resources/assert.js';
class C {
@@ -14,4 +15,4 @@ class C {
var d = new C().d();
-assert.throw(() => { d.x = 'string'}, chai.AssertionError);
+assert.throw(() => { d.x = 'string'}, AssertionError);
@@ -2,6 +2,6 @@
// Error: Specified as ./resources/no_such_file.js.
// Error: Imported by test/feature/Modules/Error_InvalidModuleDeclaration.module.js.
// Error: Normalizes to test/feature/Modules/resources/no_such_file.js
-// Error: locate resolved against base './'
+// Error: locate resolved against base
import * as b from './resources/no_such_file.js';
@@ -1 +1,3 @@
-assert.equal(__moduleName, 'test/feature/Modules/ModuleName.module.js');
+var re = /([^\s']+?)(?=test(?:[\/\\])feature(?:[\/\\]))/g;
+
+assert.equal(__moduleName.replace(re, ''), 'test/feature/Modules/ModuleName.module.js');
@@ -1,5 +1,5 @@
-// Error: :6:11: implements is a reserved identifier,
-// Error: :11:11: yield is a reserved identifier,
+// Error: :6:11: implements is a reserved identifier
+// Error: :11:11: yield is a reserved identifier
function f() {
'use strict';
@@ -1,4 +1,4 @@
-// Error: :8:25: implements is a reserved identifier,
+// Error: :8:25: implements is a reserved identifier
// Error :8:25: implements is a reserved identifier
// Error :10:1: implements is a reserved identifier
// Error :11:2: implements is a reserved identifier
@@ -1,4 +1,6 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
+
class Test {
single(a: number) { return true; }
multiple(a: number, b: boolean) { return true; }
@@ -19,9 +21,9 @@ test.name = 'me';
assert.equal(1, test.initialized());
assert.equal(2, test.initialized(2));
-assert.throw(() => { test.single(''); }, chai.AssertionError);
-assert.throw(() => { test.multiple('', false); }, chai.AssertionError);
-assert.throw(() => { test.multiple(false, 1); }, chai.AssertionError);
-assert.throw(() => { test.multiple(1, ''); }, chai.AssertionError);
-assert.throw(() => { test.initialized(''); }, chai.AssertionError);
-assert.throw(() => { test.name = 123; }, chai.AssertionError);
+assert.throw(() => { test.single(''); }, AssertionError);
+assert.throw(() => { test.multiple('', false); }, AssertionError);
+assert.throw(() => { test.multiple(false, 1); }, AssertionError);
+assert.throw(() => { test.multiple(1, ''); }, AssertionError);
+assert.throw(() => { test.initialized(''); }, AssertionError);
+assert.throw(() => { test.name = 123; }, AssertionError);
@@ -1,4 +1,6 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
+
class Test {
simple(): number { return 1; }
@@ -20,8 +22,8 @@ var test = new Test();
assert.equal(1, Test.staticGetter);
assert.equal(1, Test.staticSimple());
-assert.throw(Test.staticThrowsAssertion, chai.AssertionError);
+assert.throw(Test.staticThrowsAssertion, AssertionError);
assert.equal(1, test.getter);
assert.equal(1, test.simple());
-assert.throw(test.throwsAssertion, chai.AssertionError);
+assert.throw(test.throwsAssertion, AssertionError);
@@ -1,6 +1,9 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+
+import {AssertionError} from '../../asserts.js';
+
function initialized(a: number = 1) { return a; }
assert.equal(1, initialized());
assert.equal(2, initialized(2));
-assert.throw(() => { initialized(''); }, chai.AssertionError);
+assert.throw(() => { initialized(''); }, AssertionError);
@@ -1,7 +1,8 @@
// Options: --types --type-assertions
import {exportedParamAndReturn} from './resources/exported-function.js';
+import {AssertionError} from '../../asserts.js';
assert.equal(1, exportedParamAndReturn(1));
-assert.throw(() => { exportedParamAndReturn(''); }, chai.AssertionError);
-assert.throw(() => { exportedParamAndReturn(0); }, chai.AssertionError);
+assert.throw(() => { exportedParamAndReturn(''); }, AssertionError);
+assert.throw(() => { exportedParamAndReturn(0); }, AssertionError);
@@ -1,4 +1,6 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
+
function single(a: number) {}
function multiple(a: number, b: boolean) {}
function untyped(a) {}
@@ -9,8 +11,8 @@ multiple(1, true);
untyped();
onlySome(null, 1);
-assert.throw(() => { single(''); }, chai.AssertionError);
-assert.throw(() => { multiple('', false); }, chai.AssertionError);
-assert.throw(() => { multiple(false, 1); }, chai.AssertionError);
-assert.throw(() => { multiple(1, ''); }, chai.AssertionError);
-assert.throw(() => { onlySome(1, true); }, chai.AssertionError);
+assert.throw(() => { single(''); }, AssertionError);
+assert.throw(() => { multiple('', false); }, AssertionError);
+assert.throw(() => { multiple(false, 1); }, AssertionError);
+assert.throw(() => { multiple(1, ''); }, AssertionError);
+assert.throw(() => { onlySome(1, true); }, AssertionError);
@@ -1,4 +1,7 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+
+import {AssertionError} from '../../asserts.js';
+
function returnType(): number { return 1; }
function multipleReturnPaths(value): number {
@@ -74,4 +77,4 @@ assert.isFalse(returnWithinDoWhileLoop(20));
assert.equal(0, returnExpression(0));
assert.equal(2, returnExpression(4));
assert.equal(undefined, returnVoid());
-assert.throw(throwsAssertion, chai.AssertionError);
+assert.throw(throwsAssertion, AssertionError);
@@ -1,4 +1,6 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
+
function f(value: string, a: Function = function(): Function {
// body of default param expression
return function (x: string): number {
@@ -13,6 +15,6 @@ function f(value: string, a: Function = function(): Function {
assert.equal(5, f('hello'));
assert.equal(10, f('hello', () => { return () => { return 10; }}));
-assert.throw(() => { f(1); }, chai.AssertionError);
-assert.throw(() => { f('hello', 1); }, chai.AssertionError);
-assert.throw(() => { f('invalid'); }, chai.AssertionError);
+assert.throw(() => { f(1); }, AssertionError);
+assert.throw(() => { f('hello', 1); }, AssertionError);
+assert.throw(() => { f('invalid'); }, AssertionError);
@@ -1,4 +1,5 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
function foo(a: string): boolean {
var x: number = 1;
@@ -15,6 +16,6 @@ function failVariable() {
foo('bar');
-assert.throw(() => { foo(123) }, chai.AssertionError);
-assert.throw(() => { failReturn() }, chai.AssertionError);
-assert.throw(() => { failVariable() }, chai.AssertionError);
+assert.throw(() => { foo(123) }, AssertionError);
+assert.throw(() => { failReturn() }, AssertionError);
+assert.throw(() => { failVariable() }, AssertionError);
@@ -1,4 +1,6 @@
// Options: --types --type-assertions --type-assertion-module=./resources/assert.js
+import {AssertionError} from '../../asserts.js';
+
var globalVar: number = 1;
var globalUninitializedVar: number;
@@ -13,4 +15,4 @@ function throwsAssertion(value) {
var x: number = value;
}
-assert.throw(() => { throwsAssertion('test'); }, chai.AssertionError);
+assert.throw(() => { throwsAssertion('test'); }, AssertionError);
@@ -1,4 +1,4 @@
-export var assert = chai.assert;
+export * from '../../../asserts.js';
assert.type = function (actual, type) {
if (type === $traceurRuntime.type.any) {
Oops, something went wrong.

0 comments on commit 5ac6675

Please sign in to comment.