mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Remove useOldFrontend from compiler_helper
Change-Id: Ief047cc08b3df47be3381336ec37ed24c53e6302 Reviewed-on: https://dart-review.googlesource.com/53980 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
4b53f7e0d2
commit
9bac9ee596
76 changed files with 383 additions and 630 deletions
|
@ -78,29 +78,19 @@ main() {
|
|||
var timesOne = new RegExp(r"\* 1");
|
||||
var oneTimes = new RegExp(r"1 \*");
|
||||
|
||||
test({bool useKernel}) async {
|
||||
await compileAndDoNotMatch(INT_PLUS_ZERO, 'main', plusZero,
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(ZERO_PLUS_INT, 'main', zeroPlus,
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(NUM_PLUS_ZERO, 'main', plusZero,
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(ZERO_PLUS_NUM, 'main', zeroPlus,
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(INT_TIMES_ONE, 'main', timesOne,
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(ONE_TIMES_INT, 'main', oneTimes,
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(NUM_TIMES_ONE, 'main', timesOne,
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(ONE_TIMES_NUM, 'main', oneTimes,
|
||||
useKernel: useKernel);
|
||||
test() async {
|
||||
await compileAndDoNotMatch(INT_PLUS_ZERO, 'main', plusZero);
|
||||
await compileAndDoNotMatch(ZERO_PLUS_INT, 'main', zeroPlus);
|
||||
await compileAndMatch(NUM_PLUS_ZERO, 'main', plusZero);
|
||||
await compileAndMatch(ZERO_PLUS_NUM, 'main', zeroPlus);
|
||||
await compileAndDoNotMatch(INT_TIMES_ONE, 'main', timesOne);
|
||||
await compileAndDoNotMatch(ONE_TIMES_INT, 'main', oneTimes);
|
||||
await compileAndDoNotMatch(NUM_TIMES_ONE, 'main', timesOne);
|
||||
await compileAndDoNotMatch(ONE_TIMES_NUM, 'main', oneTimes);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await test(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await test(useKernel: true);
|
||||
await test();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ foo(a) {
|
|||
|
||||
main() {
|
||||
test({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r'.add$1('));
|
||||
Expect.isTrue(generated.contains(r'.removeLast$0('));
|
||||
Expect.isTrue(generated.contains(r'.length'),
|
||||
|
@ -26,8 +25,6 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await test(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await test(useKernel: true);
|
||||
});
|
||||
|
|
|
@ -17,17 +17,14 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
test({bool useKernel}) async {
|
||||
await compile(TEST, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
test() async {
|
||||
await compile(TEST, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains('foo() !== true)'));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await test(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await test(useKernel: true);
|
||||
await test();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,11 +18,9 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
test({bool useKernel}) async {
|
||||
await compile(TEST,
|
||||
entry: 'foo',
|
||||
enableTypeAssertions: true,
|
||||
useKernel: useKernel, check: (String generated) {
|
||||
test() async {
|
||||
await compile(TEST, entry: 'foo', enableTypeAssertions: true,
|
||||
check: (String generated) {
|
||||
Expect.isTrue(!generated.contains('eqB'));
|
||||
|
||||
RegExp regexp = new RegExp('==');
|
||||
|
@ -32,9 +30,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await test(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await test(useKernel: true);
|
||||
await test();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,25 +25,20 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
test({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
test() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains("return 3;"));
|
||||
});
|
||||
await compile(TEST_TWO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains("return 3;"));
|
||||
});
|
||||
await compile(TEST_THREE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_THREE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains("push(2);"));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await test(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await test(useKernel: true);
|
||||
await test();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -89,17 +89,15 @@ main() {
|
|||
// { a: true, }. Make sure this doesn't happen again.
|
||||
RegExp danglingComma = new RegExp(r',[ \n]*}');
|
||||
|
||||
Future runTests({bool useKernel}) async {
|
||||
Future runTests() async {
|
||||
for (String test in [TEST_ONE, TEST_TWO, TEST_THREE, TEST_FOUR]) {
|
||||
String generated = await compileAll(test, useKernel: useKernel);
|
||||
String generated = await compileAll(test);
|
||||
Expect.isFalse(danglingComma.hasMatch(generated));
|
||||
}
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -63,45 +63,43 @@ main() {
|
|||
}
|
||||
""";
|
||||
|
||||
twoClasses({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST_ONE, useKernel: useKernel);
|
||||
twoClasses() async {
|
||||
String generated = await compileAll(TEST_ONE);
|
||||
Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"')));
|
||||
Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "Object;"')));
|
||||
}
|
||||
|
||||
subClass({bool useKernel}) async {
|
||||
subClass() async {
|
||||
checkOutput(String generated) {
|
||||
Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"')));
|
||||
Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "A;"')));
|
||||
}
|
||||
|
||||
checkOutput(await compileAll(TEST_TWO, useKernel: useKernel));
|
||||
checkOutput(await compileAll(TEST_THREE, useKernel: useKernel));
|
||||
checkOutput(await compileAll(TEST_TWO));
|
||||
checkOutput(await compileAll(TEST_THREE));
|
||||
}
|
||||
|
||||
fieldTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST_FOUR, useKernel: useKernel);
|
||||
fieldTest() async {
|
||||
String generated = await compileAll(TEST_FOUR);
|
||||
Expect.isTrue(generated
|
||||
.contains(new RegExp('B: {[ \n]*"\\^": "A;y,z,x",[ \n]*static:')));
|
||||
}
|
||||
|
||||
constructor1({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST_FIVE, useKernel: useKernel);
|
||||
constructor1() async {
|
||||
String generated = await compileAll(TEST_FIVE);
|
||||
Expect.isTrue(generated.contains(new RegExp(r"new [$A-Z]+\.A\(a\);")));
|
||||
}
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await twoClasses(useKernel: useKernel);
|
||||
await subClass(useKernel: useKernel);
|
||||
await fieldTest(useKernel: useKernel);
|
||||
await constructor1(useKernel: useKernel);
|
||||
runTests() async {
|
||||
await twoClasses();
|
||||
await subClass();
|
||||
await fieldTest();
|
||||
await constructor1();
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -36,18 +36,16 @@ main() {
|
|||
// we just verify that their members are in the correct order.
|
||||
RegExp regexp = new RegExp(r"foo\$0?:(.|\n)*bar\$0:(.|\n)*gee\$0:");
|
||||
|
||||
runTests({bool useKernel}) async {
|
||||
String generated1 = await compileAll(TEST_ONE, useKernel: useKernel);
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(TEST_ONE);
|
||||
Expect.isTrue(regexp.hasMatch(generated1));
|
||||
|
||||
String generated2 = await compileAll(TEST_TWO, useKernel: useKernel);
|
||||
String generated2 = await compileAll(TEST_TWO);
|
||||
Expect.isTrue(regexp.hasMatch(generated2));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,44 +41,37 @@ class A {
|
|||
main() { new A().foo(1); }
|
||||
""";
|
||||
|
||||
Future closureInvocation({bool useKernel, bool minify, String prefix}) async {
|
||||
await compile(TEST_INVOCATION0, useKernel: useKernel, minify: minify,
|
||||
check: (String generated) {
|
||||
Future closureInvocation({bool minify, String prefix}) async {
|
||||
await compile(TEST_INVOCATION0, minify: minify, check: (String generated) {
|
||||
Expect.isTrue(generated.contains(".$prefix\$0()"));
|
||||
});
|
||||
await compile(TEST_INVOCATION1, useKernel: useKernel, minify: minify,
|
||||
check: (String generated) {
|
||||
await compile(TEST_INVOCATION1, minify: minify, check: (String generated) {
|
||||
Expect.isTrue(generated.contains(".$prefix\$1(1)"));
|
||||
});
|
||||
await compile(TEST_INVOCATION2, useKernel: useKernel, minify: minify,
|
||||
check: (String generated) {
|
||||
await compile(TEST_INVOCATION2, minify: minify, check: (String generated) {
|
||||
Expect.isTrue(generated.contains(".$prefix\$2(1,${minify ? "" : " "}2)"));
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure that the bailout version does not introduce a second version of
|
||||
// the closure.
|
||||
Future closureBailout({bool useKernel, bool minify, String prefix}) async {
|
||||
String generated =
|
||||
await compileAll(TEST_BAILOUT, useKernel: useKernel, minify: minify);
|
||||
Future closureBailout({bool minify, String prefix}) async {
|
||||
String generated = await compileAll(TEST_BAILOUT, minify: minify);
|
||||
RegExp regexp = new RegExp("$prefix\\\$0:${minify ? "" : " "}function");
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await closureInvocation(
|
||||
useKernel: useKernel, minify: false, prefix: "call");
|
||||
await closureInvocation(useKernel: useKernel, minify: true, prefix: "");
|
||||
await closureBailout(useKernel: useKernel, minify: false, prefix: "call");
|
||||
await closureBailout(useKernel: useKernel, minify: true, prefix: "");
|
||||
runTests() async {
|
||||
await closureInvocation(minify: false, prefix: "call");
|
||||
await closureInvocation(minify: true, prefix: "");
|
||||
await closureBailout(minify: false, prefix: "call");
|
||||
await closureBailout(minify: true, prefix: "");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ foo(int a, int b, bool param2) {
|
|||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, useKernel: useKernel, entry: 'foo',
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp('a \\+ b');
|
||||
Iterator matches = regexp.allMatches(generated).iterator;
|
||||
Expect.isTrue(matches.moveNext());
|
||||
|
|
|
@ -33,21 +33,15 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compileAndMatch(TEST_1, 'foo', new RegExp(r'return 72'),
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(TEST_1, 'foo', new RegExp(r'Hello'),
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(TEST_2, 'foo', new RegExp(r'Hello'),
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(TEST_3, 'foo', new RegExp(r'Hello'),
|
||||
useKernel: useKernel);
|
||||
runTests() async {
|
||||
await compileAndMatch(TEST_1, 'foo', new RegExp(r'return 72'));
|
||||
await compileAndDoNotMatch(TEST_1, 'foo', new RegExp(r'Hello'));
|
||||
await compileAndMatch(TEST_2, 'foo', new RegExp(r'Hello'));
|
||||
await compileAndMatch(TEST_3, 'foo', new RegExp(r'Hello'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -57,14 +57,11 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compileAndMatch(NUMBER_FOLDING, 'main', new RegExp(r"print\(7\)"),
|
||||
useKernel: useKernel);
|
||||
runTests() async {
|
||||
await compileAndMatch(NUMBER_FOLDING, 'main', new RegExp(r"print\(7\)"));
|
||||
await compileAndMatch(
|
||||
NEGATIVE_NUMBER_FOLDING, 'main', new RegExp(r"print\(1\)"),
|
||||
useKernel: useKernel);
|
||||
await compile(NULL_EQUALS_FOLDING, useKernel: useKernel, entry: 'foo',
|
||||
check: (String generated) {
|
||||
NEGATIVE_NUMBER_FOLDING, 'main', new RegExp(r"print\(1\)"));
|
||||
await compile(NULL_EQUALS_FOLDING, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp(r'a == null');
|
||||
Expect.isTrue(regexp.hasMatch(generated));
|
||||
|
||||
|
@ -77,23 +74,17 @@ main() {
|
|||
regexp = new RegExp('"foo" === d');
|
||||
Expect.isTrue(regexp.hasMatch(generated));
|
||||
});
|
||||
await compileAndMatch(LIST_LENGTH_FOLDING, 'foo', new RegExp(r"return 3"),
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"return 1"),
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"ioore"),
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(STRING_LENGTH_FOLDING, 'foo', new RegExp(r"return 3"),
|
||||
useKernel: useKernel);
|
||||
await compileAndMatch(LIST_LENGTH_FOLDING, 'foo', new RegExp(r"return 3"));
|
||||
await compileAndMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"return 1"));
|
||||
await compileAndDoNotMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"ioore"));
|
||||
await compileAndMatch(
|
||||
RANGE_ERROR_INDEX_FOLDING, 'foo', new RegExp(r"ioore"),
|
||||
useKernel: useKernel);
|
||||
STRING_LENGTH_FOLDING, 'foo', new RegExp(r"return 3"));
|
||||
await compileAndMatch(
|
||||
RANGE_ERROR_INDEX_FOLDING, 'foo', new RegExp(r"ioore"));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,9 +27,8 @@ main() {
|
|||
Expect.isTrue(generated.contains(text), text);
|
||||
}
|
||||
|
||||
runTests({bool useKernel}) async {
|
||||
String generated =
|
||||
await compile(TEST_ONE, useKernel: useKernel, entry: 'test');
|
||||
runTests() async {
|
||||
String generated = await compile(TEST_ONE, entry: 'test');
|
||||
check(generated, '.List_12_53.');
|
||||
check(generated, '.Token_start_null.');
|
||||
check(generated, '.Token_end_null.');
|
||||
|
@ -38,9 +37,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,15 +17,13 @@ foo(a) {
|
|||
''';
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
Expect.isFalse(generated.contains('return 42'), 'dead code not eliminated');
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,18 +18,15 @@ void foo(bar) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, useKernel: useKernel, entry: 'foo',
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp("toBeRemoved");
|
||||
Expect.isTrue(!regexp.hasMatch(generated));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ main() {
|
|||
// For a function with only one variable we declare it inline for more
|
||||
// compactness. Test that we don't also declare it at the start of the
|
||||
// method.
|
||||
runTest({bool useKernel}) async {
|
||||
runTest() async {
|
||||
String generated = await compile(
|
||||
'final List a = const ["bar", "baz"];'
|
||||
'int foo() {'
|
||||
|
@ -19,7 +19,6 @@ main() {
|
|||
' print(a[i]);'
|
||||
' }'
|
||||
'}',
|
||||
useKernel: useKernel,
|
||||
entry: 'foo',
|
||||
minify: false);
|
||||
RegExp re = new RegExp(r"var ");
|
||||
|
@ -29,9 +28,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ main() {
|
|||
''';
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
String generated1 = await compileAll(TEST1, useKernel: useKernel);
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(TEST1);
|
||||
// Direct call through field.
|
||||
Expect.isTrue(generated1.contains(r'this._fun.call$1(zzz)'));
|
||||
// No stub.
|
||||
|
@ -47,7 +47,7 @@ main() {
|
|||
// No call to stub.
|
||||
Expect.isFalse(generated1.contains(r'_fun$1('));
|
||||
|
||||
String generated2 = await compileAll(TEST2, useKernel: useKernel);
|
||||
String generated2 = await compileAll(TEST2);
|
||||
// No call through field.
|
||||
Expect.isFalse(generated2.contains(r'this._fun.call$1(zzz)'));
|
||||
// Call through stub.
|
||||
|
@ -59,9 +59,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,16 +19,14 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST_GUIDE, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST_GUIDE);
|
||||
Expect.isTrue(generated.contains("42"));
|
||||
Expect.isFalse(generated.contains("TITLE"));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,18 +20,16 @@ main() { return x; }
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
String generated1 = await compileAll(TEST_NULL0, useKernel: useKernel);
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(TEST_NULL0);
|
||||
Expect.isTrue(generated1.contains("null"));
|
||||
|
||||
String generated2 = await compileAll(TEST_NULL1, useKernel: useKernel);
|
||||
String generated2 = await compileAll(TEST_NULL1);
|
||||
Expect.isTrue(generated2.contains("null"));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -82,17 +82,14 @@ void main() {
|
|||
|
||||
main() {
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
test(String code, Function f) async {
|
||||
String generated =
|
||||
await compileAll(code, disableInlining: true, useKernel: useKernel);
|
||||
String generated = await compileAll(code, disableInlining: true);
|
||||
Expect.isTrue(f(generated));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,19 +28,17 @@ foo(a) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(!generated.contains(r'break'));
|
||||
}, useKernel: useKernel);
|
||||
});
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r'continue'));
|
||||
}, useKernel: useKernel);
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,19 +40,16 @@ main() {
|
|||
''';
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
String generated1 =
|
||||
await compileAll(SHOULD_NOT_BE_BOXED_TEST, useKernel: useKernel);
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(SHOULD_NOT_BE_BOXED_TEST);
|
||||
Expect.isTrue(generated1.contains('main_closure(i)'),
|
||||
'for-loop variable should not have been boxed');
|
||||
|
||||
String generated2 =
|
||||
await compileAll(SHOULD_BE_BOXED_TEST, useKernel: useKernel);
|
||||
String generated2 = await compileAll(SHOULD_BE_BOXED_TEST);
|
||||
Expect.isFalse(generated2.contains('main_closure(i)'),
|
||||
'for-loop variable should have been boxed');
|
||||
|
||||
String generated3 =
|
||||
await compileAll(ONLY_UPDATE_LOOP_VAR_TEST, useKernel: useKernel);
|
||||
String generated3 = await compileAll(ONLY_UPDATE_LOOP_VAR_TEST);
|
||||
Expect.isFalse(generated3.contains('main_closure(i)'),
|
||||
'for-loop variable should have been boxed');
|
||||
Expect.isFalse(generated3.contains(', _box_0.b = 3,'),
|
||||
|
@ -60,9 +57,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,16 +50,13 @@ foo(a) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
// Make sure we don't introduce a new variable.
|
||||
await compileAndDoNotMatch(FIB, 'fib', new RegExp("var $anyIdentifier ="),
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(FIB, 'fib', new RegExp("var $anyIdentifier ="));
|
||||
|
||||
await compileAndDoNotMatch(BAR, 'bar', new RegExp("isLeaf"),
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(BAR, 'bar', new RegExp("isLeaf"));
|
||||
|
||||
await compile(TEST, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST, entry: 'foo', check: (String generated) {
|
||||
Expect.isFalse(generated.contains('else'));
|
||||
// Regression check to ensure that there is no floating variable
|
||||
// expression.
|
||||
|
@ -68,9 +65,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -106,46 +106,40 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTests() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp(r"1 \+ [a-z]+");
|
||||
checkNumberOfMatches(regexp.allMatches(generated).iterator, 1);
|
||||
});
|
||||
await compile(TEST_TWO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
checkNumberOfMatches(
|
||||
new RegExp("length").allMatches(generated).iterator, 1);
|
||||
});
|
||||
await compile(TEST_THREE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_THREE, entry: 'foo', check: (String generated) {
|
||||
checkNumberOfMatches(
|
||||
new RegExp("number").allMatches(generated).iterator, 1);
|
||||
});
|
||||
await compile(TEST_FOUR, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_FOUR, entry: 'foo', check: (String generated) {
|
||||
checkNumberOfMatches(new RegExp("shr").allMatches(generated).iterator, 1);
|
||||
});
|
||||
|
||||
await compileAll(TEST_FIVE, useKernel: useKernel).then((generated) {
|
||||
await compileAll(TEST_FIVE).then((generated) {
|
||||
checkNumberOfMatches(
|
||||
new RegExp("get\\\$foo").allMatches(generated).iterator, 1);
|
||||
});
|
||||
await compileAll(TEST_SIX, useKernel: useKernel).then((generated) {
|
||||
await compileAll(TEST_SIX).then((generated) {
|
||||
Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)'));
|
||||
});
|
||||
await compileAll(TEST_SEVEN, useKernel: useKernel).then((generated) {
|
||||
await compileAll(TEST_SEVEN).then((generated) {
|
||||
Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)'));
|
||||
});
|
||||
await compileAll(TEST_EIGHT, useKernel: useKernel).then((generated) {
|
||||
await compileAll(TEST_EIGHT).then((generated) {
|
||||
Expect.isTrue(generated.contains('for (; i < t1; ++i)'));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,9 +16,8 @@ bool foo(bar) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
// Check that no boolify code is generated.
|
||||
RegExp regexp = new RegExp("=== true");
|
||||
Iterator matches = regexp.allMatches(generated).iterator;
|
||||
|
@ -32,9 +31,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,9 +19,8 @@ foo(param0, param1, param2) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST, entry: 'foo', check: (String generated) {
|
||||
// Check that the do-while in the 'then' is enclosed in braces.
|
||||
// Otherwise Android 4.0 stock browser has a syntax error. See issue 10923.
|
||||
Expect.isTrue(
|
||||
|
@ -30,9 +29,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,17 +23,15 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST1, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST1);
|
||||
// Check that we're using the index operator on the object returned
|
||||
// by the A factory.
|
||||
Expect.isTrue(generated.contains('[0] = 42'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,19 +14,16 @@ const String TEST_ONE = r"""
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
runTest() async {
|
||||
// Check that almost-constant interceptor is used.
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
String re = r'a && [\w\.]*_methods';
|
||||
Expect.isTrue(generated.contains(new RegExp(re)), 'contains /$re/');
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,11 +25,10 @@ const String TEST_TWO = r"""
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
// Check that one-shot interceptors preserve variable names, see
|
||||
// https://code.google.com/p/dart/issues/detail?id=8106.
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(
|
||||
generated.contains(new RegExp(r'[$A-Z]+\.toString\$0\$\(a\)')));
|
||||
Expect.isTrue(generated.contains('myVariableName'));
|
||||
|
@ -37,8 +36,7 @@ main() {
|
|||
// Check that an intercepted getter that does not need to be
|
||||
// intercepted, is turned into a regular getter call or field
|
||||
// access.
|
||||
await compile(TEST_TWO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
Expect.isFalse(generated.contains(r'a.get$length()'));
|
||||
Expect
|
||||
.isTrue(generated.contains(new RegExp(r'[$A-Z]+\.A\$\(\)\.length')));
|
||||
|
@ -48,9 +46,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,10 +38,9 @@ const String TEST_4 = r"""
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
check(String test, String contained) async {
|
||||
String generated =
|
||||
await compile(test, entry: 'foo', useKernel: useKernel);
|
||||
String generated = await compile(test, entry: 'foo');
|
||||
Expect.isTrue(generated.contains(contained), contained);
|
||||
}
|
||||
|
||||
|
@ -61,9 +60,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,15 +17,13 @@ main() {
|
|||
}""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
runTest() async {
|
||||
// Make sure we don't introduce a new variable.
|
||||
await compileAndMatchFuzzy(MAIN, 'main', "1 >= x", useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(MAIN, 'main', "1 >= x");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ negate(x) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_IF_BOOL_FIRST_INSTRUCTION,
|
||||
entry: 'negate', useKernel: useKernel, check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_IF_BOOL_FIRST_INSTRUCTION, entry: 'negate',
|
||||
check: (String generated) {
|
||||
Expect.isTrue(generated.contains("!")); // We want to see !x.
|
||||
Expect.isFalse(generated.contains("!=")); // And not !== true.
|
||||
Expect.isFalse(generated.contains("true"));
|
||||
|
@ -25,9 +25,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,9 +71,8 @@ test(param) {
|
|||
}
|
||||
""";
|
||||
|
||||
Future compileAndTest(String code, {bool useKernel}) {
|
||||
return compile(code, entry: 'test', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
Future compileAndTest(String code) {
|
||||
return compile(code, entry: 'test', check: (String generated) {
|
||||
RegExp validAdd =
|
||||
new RegExp("($anyIdentifier \\+ 42)|($anyIdentifier \\+= 42)");
|
||||
RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53");
|
||||
|
@ -83,19 +82,17 @@ Future compileAndTest(String code, {bool useKernel}) {
|
|||
}
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compileAndTest(TEST_IF, useKernel: useKernel);
|
||||
await compileAndTest(TEST_IF_ELSE, useKernel: useKernel);
|
||||
await compileAndTest(TEST_IF_RETURN, useKernel: useKernel);
|
||||
await compileAndTest(TEST_IF_NOT_ELSE, useKernel: useKernel);
|
||||
await compileAndTest(TEST_IF_NOT_RETURN, useKernel: useKernel);
|
||||
await compileAndTest(TEST_IF_NOT_ELSE_RETURN, useKernel: useKernel);
|
||||
runTests() async {
|
||||
await compileAndTest(TEST_IF);
|
||||
await compileAndTest(TEST_IF_ELSE);
|
||||
await compileAndTest(TEST_IF_RETURN);
|
||||
await compileAndTest(TEST_IF_NOT_ELSE);
|
||||
await compileAndTest(TEST_IF_NOT_RETURN);
|
||||
await compileAndTest(TEST_IF_NOT_ELSE_RETURN);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,16 +24,13 @@ main() {
|
|||
''';
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
runTest() async {
|
||||
await compileAndMatch(TEST, 'main',
|
||||
new RegExp('if \\(typeof count !== "number"\\)(.|\\n)*while'),
|
||||
useKernel: useKernel);
|
||||
new RegExp('if \\(typeof count !== "number"\\)(.|\\n)*while'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ main() {
|
|||
""";
|
||||
|
||||
checkRangeError(String test, {bool hasRangeError}) async {
|
||||
String generated = await compileAll(test, useKernel: false);
|
||||
String generated = await compileAll(test);
|
||||
Expect.equals(
|
||||
hasRangeError,
|
||||
generated.contains('ioore'),
|
||||
|
|
|
@ -69,24 +69,23 @@ main() {
|
|||
}
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
bool useKernel = false;
|
||||
String generated1 = await compileAll(TEST1, useKernel: useKernel);
|
||||
runTests() async {
|
||||
String generated1 = await compileAll(TEST1);
|
||||
Expect.isTrue(generated1.contains('if (typeof t1'));
|
||||
|
||||
String generated2 = await compileAll(TEST2, useKernel: useKernel);
|
||||
String generated2 = await compileAll(TEST2);
|
||||
Expect.isTrue(generated2.contains('if (typeof t1'));
|
||||
|
||||
String generated3 = await compileAll(TEST3, useKernel: useKernel);
|
||||
String generated3 = await compileAll(TEST3);
|
||||
Expect.isTrue(generated3.contains('if (typeof t1'));
|
||||
|
||||
String generated4 = await compileAll(TEST4, useKernel: useKernel);
|
||||
String generated4 = await compileAll(TEST4);
|
||||
Expect.isTrue(generated4.contains('if (typeof t1'));
|
||||
|
||||
String generated5 = await compileAll(TEST5, useKernel: useKernel);
|
||||
String generated5 = await compileAll(TEST5);
|
||||
Expect.isFalse(generated5.contains('iae'));
|
||||
|
||||
String generated6 = await compileAll(TEST6, useKernel: useKernel);
|
||||
String generated6 = await compileAll(TEST6);
|
||||
Expect.isFalse(generated6.contains('iae'));
|
||||
|
||||
var memberInvocations = const <String>[
|
||||
|
@ -100,7 +99,7 @@ main() {
|
|||
];
|
||||
for (String member in memberInvocations) {
|
||||
String generated = await compileAll(generateTest('$member'),
|
||||
expectedErrors: 0, expectedWarnings: 0, useKernel: useKernel);
|
||||
expectedErrors: 0, expectedWarnings: 0);
|
||||
Expect.isTrue(
|
||||
generated.contains('+ 42'),
|
||||
"Missing '+ 42' code for invocation '$member':\n"
|
||||
|
@ -119,9 +118,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,9 +16,8 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains('print([1, 2]);'));
|
||||
Expect.isTrue(generated.contains('print([3]);'));
|
||||
Expect.isTrue(generated.contains('print([4, 5]);'));
|
||||
|
@ -26,9 +25,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,9 +15,8 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST, entry: 'foo', check: (String generated) {
|
||||
// Make sure we have all the type information we need.
|
||||
Expect.isFalse(generated.contains('bailout'));
|
||||
Expect.isFalse(generated.contains('interceptor'));
|
||||
|
@ -28,9 +27,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -234,10 +234,9 @@ void main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
test(String code, String expected) async {
|
||||
String generated =
|
||||
await compileAll(code, disableInlining: false, useKernel: useKernel);
|
||||
String generated = await compileAll(code, disableInlining: false);
|
||||
Expect.isTrue(
|
||||
generated.contains(expected),
|
||||
"Generated code didn't contain '$expected'.\n"
|
||||
|
@ -265,9 +264,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,38 +24,29 @@ void foo(list, bar) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
// We want something like:
|
||||
// var t1 = bar.call$0() === true;
|
||||
// if (t1 || gee.call$0() === true) gee.call$0();
|
||||
// if (t1 || gee.call$0() === true) gee.call$0();
|
||||
await compileAndDoNotMatchFuzzy(
|
||||
TEST_ONE,
|
||||
'foo',
|
||||
r"""var x = [a-zA-Z0-9$.]+\(\) == true;
|
||||
TEST_ONE, 'foo', r"""var x = [a-zA-Z0-9$.]+\(\) == true;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;""",
|
||||
useKernel: useKernel);
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;""");
|
||||
|
||||
// We want something like:
|
||||
// var t1 = list == null;
|
||||
// if (t1) bar.call$0();
|
||||
// if (t1 || bar.call$0() === true) bar.call$0();
|
||||
// if (t1 || bar.call$0() === true) bar.call$0();
|
||||
await compileAndMatchFuzzy(
|
||||
TEST_TWO,
|
||||
'foo',
|
||||
r"""var x = x == null;
|
||||
await compileAndMatchFuzzy(TEST_TWO, 'foo', r"""var x = x == null;
|
||||
if \(x\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;""",
|
||||
useKernel: useKernel);
|
||||
if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;""");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -53,29 +53,23 @@ foo(a) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTests() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r'for ('));
|
||||
});
|
||||
await compile(TEST_TWO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(!generated.contains(r'break'));
|
||||
});
|
||||
await compile(TEST_THREE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_THREE, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r'continue'));
|
||||
});
|
||||
await compile(TEST_FOUR, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_FOUR, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r'continue'));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
|
|||
import '../compiler_helper.dart';
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel, int numberOfParameters}) async {
|
||||
runTests({int numberOfParameters}) async {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.write("foo(");
|
||||
for (int i = 0; i < numberOfParameters; i++) {
|
||||
|
@ -21,8 +21,7 @@ main() {
|
|||
buffer.write("$numberOfParameters; return i; }");
|
||||
String code = buffer.toString();
|
||||
|
||||
String generated =
|
||||
await compile(code, entry: 'foo', minify: true, useKernel: useKernel);
|
||||
String generated = await compile(code, entry: 'foo', minify: true);
|
||||
RegExp re = new RegExp(r"\(a,b,c");
|
||||
Expect.isTrue(re.hasMatch(generated));
|
||||
|
||||
|
@ -46,10 +45,8 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
// The [numberOfParameters] values are somewhat arbitrary.
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false, numberOfParameters: 1800);
|
||||
// The [numberOfParameters] value is somewhat arbitrary.
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true, numberOfParameters: 2000);
|
||||
await runTests(numberOfParameters: 2000);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,12 +65,9 @@ foo(param) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
check(String test) async {
|
||||
await compile(test,
|
||||
entry: 'foo',
|
||||
useKernel: useKernel,
|
||||
check: checkerForAbsentPresent(test));
|
||||
await compile(test, entry: 'foo', check: checkerForAbsentPresent(test));
|
||||
}
|
||||
|
||||
await check(MOD1);
|
||||
|
@ -82,9 +79,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,12 +26,9 @@ foo(param) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
check(String test) async {
|
||||
await compile(test,
|
||||
entry: 'foo',
|
||||
useKernel: useKernel,
|
||||
check: checkerForAbsentPresent(test));
|
||||
await compile(test, entry: 'foo', check: checkerForAbsentPresent(test));
|
||||
}
|
||||
|
||||
await check(TEST1);
|
||||
|
@ -39,9 +36,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,17 +18,15 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
|
||||
Expect.isTrue(generated
|
||||
.contains(new RegExp('A: {[ \n]*"\\^": "Object;",[ \n]*static:')));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,17 +22,15 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(CODE, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(CODE);
|
||||
RegExp regexp = new RegExp(r'A\$0: function');
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,17 +16,15 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(CODE, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(CODE);
|
||||
RegExp regexp = new RegExp(r'\A: {[ \n]*"\^": "[A-Za-z]+;"');
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,17 +29,15 @@ baz(a) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
RegExp regexp = new RegExp('foo\\\$1\\\$a: function');
|
||||
Iterator<Match> matches = regexp.allMatches(generated).iterator;
|
||||
checkNumberOfMatches(matches, 1);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,15 +17,13 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST1, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST1);
|
||||
Expect.isFalse(generated.contains('foo.length'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,17 +14,14 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
Expect.isFalse(generated.contains('typeof (void 0)'));
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,14 +19,12 @@ bool baz(int a, int b) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(SOURCE, entry: "baz", useKernel: useKernel);
|
||||
runTest() async {
|
||||
await compile(SOURCE, entry: "baz");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -72,42 +72,35 @@ int foo(var start, bool test) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compile(FOO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTests() async {
|
||||
await compile(FOO, entry: 'foo', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r"function(a, b) {"));
|
||||
});
|
||||
await compile(BAR, entry: 'bar', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(BAR, entry: 'bar', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r"function($eval, $$eval) {"));
|
||||
});
|
||||
await compile(PARAMETER_AND_TEMP, entry: 'bar', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(PARAMETER_AND_TEMP, entry: 'bar', check: (String generated) {
|
||||
Expect.isTrue(generated.contains(r"print(t00)"));
|
||||
// Check that the second 't0' got another name.
|
||||
Expect.isTrue(generated.contains(r"print(t01)"));
|
||||
});
|
||||
await compile(MULTIPLE_PHIS_ONE_LOCAL, entry: 'foo', useKernel: useKernel,
|
||||
await compile(MULTIPLE_PHIS_ONE_LOCAL, entry: 'foo',
|
||||
check: (String generated) {
|
||||
Expect.isTrue(generated.contains("var a;"));
|
||||
// Check that there is only one var declaration.
|
||||
checkNumberOfMatches(new RegExp("var").allMatches(generated).iterator, 1);
|
||||
});
|
||||
await compile(NO_LOCAL, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(NO_LOCAL, entry: 'foo', check: (String generated) {
|
||||
Expect.isFalse(generated.contains('var'));
|
||||
});
|
||||
await compile(PARAMETER_INIT, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(PARAMETER_INIT, entry: 'foo', check: (String generated) {
|
||||
// Check that there is only one var declaration.
|
||||
checkNumberOfMatches(new RegExp("var").allMatches(generated).iterator, 1);
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,14 +28,12 @@ void foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTests() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp("toBeRemoved");
|
||||
Expect.isTrue(!regexp.hasMatch(generated));
|
||||
});
|
||||
await compile(TEST_TWO, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_TWO, entry: 'foo', check: (String generated) {
|
||||
RegExp regexp = new RegExp("toBeRemoved");
|
||||
Expect.isTrue(!regexp.hasMatch(generated));
|
||||
regexp = new RegExp("temp");
|
||||
|
@ -44,9 +42,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,18 +25,15 @@ main() {
|
|||
""";
|
||||
|
||||
void main() {
|
||||
runTests({bool useKernel}) async {
|
||||
String code =
|
||||
await compile(SOURCE, useKernel: useKernel, methodName: 'test');
|
||||
runTests() async {
|
||||
String code = await compile(SOURCE, methodName: 'test');
|
||||
Expect.isNotNull(code);
|
||||
Expect.equals(0, new RegExp('add').allMatches(code).length);
|
||||
Expect.equals(3, new RegExp('\\+').allMatches(code).length);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,16 +23,14 @@ main() {
|
|||
''';
|
||||
|
||||
void main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
Expect.isTrue(generated.contains('return c + c;'),
|
||||
"Expected generated code to contain 'return c + c;':\n$generated");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel----------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,9 +51,8 @@ foo() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST, entry: 'foo', check: (String generated) {
|
||||
for (int i = 0; i <= 15; i++) {
|
||||
String predicateCheck = '.\$is_args$i';
|
||||
Expect.isTrue(generated.contains(predicateCheck),
|
||||
|
@ -65,9 +64,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ main() {
|
|||
""";
|
||||
|
||||
void main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
if (generated.contains(r'=== true')) {
|
||||
print(generated);
|
||||
Expect.fail("missing elision of '=== true'");
|
||||
|
@ -59,9 +59,7 @@ void main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -69,39 +69,29 @@ void main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await compileAndMatchFuzzy(TEST_ONE, 'foo', "var x = x === true \\? 2 : 3;",
|
||||
useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_ONE, 'foo', "print\\(x\\);",
|
||||
useKernel: useKernel);
|
||||
runTests() async {
|
||||
await compileAndMatchFuzzy(
|
||||
TEST_ONE, 'foo', "var x = x === true \\? 2 : 3;");
|
||||
await compileAndMatchFuzzy(TEST_ONE, 'foo', "print\\(x\\);");
|
||||
|
||||
await compileAndMatchFuzzy(TEST_TWO, 'main', "x \\+= 10",
|
||||
useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_TWO, 'main', "\\+\\+x",
|
||||
useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_TWO, 'main', "x \\+= 10");
|
||||
await compileAndMatchFuzzy(TEST_TWO, 'main', "\\+\\+x");
|
||||
|
||||
// Check that we don't have 'd = d' (using regexp back references).
|
||||
await compileAndDoNotMatchFuzzy(TEST_THREE, 'foo', '(x) = \1',
|
||||
useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_THREE, 'foo', 'return x',
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatchFuzzy(TEST_THREE, 'foo', '(x) = \1');
|
||||
await compileAndMatchFuzzy(TEST_THREE, 'foo', 'return x');
|
||||
|
||||
// Check that a store just after the declaration of the local
|
||||
// only generates one instruction.
|
||||
await compileAndMatchFuzzy(TEST_THREE, 'foo', 'x = 42',
|
||||
useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_THREE, 'foo', 'x = 42');
|
||||
|
||||
await compileAndDoNotMatchFuzzy(TEST_FOUR, 'foo', '(x) = \1;',
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatchFuzzy(TEST_FOUR, 'foo', '(x) = \1;');
|
||||
|
||||
await compileAndDoNotMatch(TEST_FIVE, 'main', new RegExp('hash0'),
|
||||
useKernel: useKernel);
|
||||
await compileAndDoNotMatch(TEST_FIVE, 'main', new RegExp('hash0'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,9 +9,8 @@ import "package:async_helper/async_helper.dart";
|
|||
import '../compiler_helper.dart';
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String code =
|
||||
await compileAll(r'''main() { print(main); }''', useKernel: useKernel);
|
||||
runTest() async {
|
||||
String code = await compileAll(r'''main() { print(main); }''');
|
||||
// At some point, we will have to closurize global functions
|
||||
// differently, at which point this test will break. Then it is time
|
||||
// to implement a way to call a Dart closure from JS foreign
|
||||
|
@ -26,9 +25,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel----------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,17 +24,15 @@ void main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
runTest() async {
|
||||
// The `==` is strengthened to a HIdentity instruction. The HIdentity follows
|
||||
// `x.link`, so x cannot be `null`.
|
||||
var compare = new RegExp(r'x === x\.get\$link\(\)');
|
||||
await compileAndMatch(CODE, 'main', compare, useKernel: useKernel);
|
||||
await compileAndMatch(CODE, 'main', compare);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,16 +7,13 @@ import "package:async_helper/async_helper.dart";
|
|||
import '../compiler_helper.dart';
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String code = await compileAll(r'''main() { return "foo" + "bar"; }''',
|
||||
useKernel: useKernel);
|
||||
runTest() async {
|
||||
String code = await compileAll(r'''main() { return "foo" + "bar"; }''');
|
||||
Expect.isTrue(!code.contains(r'$add'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,75 +10,94 @@ import '../compiler_helper.dart';
|
|||
// Test that the compiler handles string literals containing line terminators.
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
Future<String> compileExpression(String expression) {
|
||||
var source = "foo() { return $expression; }";
|
||||
return compile(source, entry: "foo", useKernel: useKernel);
|
||||
return compile(source, entry: "foo");
|
||||
}
|
||||
|
||||
await compileExpression("''' \n\r\u2028\u2029'''").then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression("r''' \n\r\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression("r''' \r\n\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression("r''' \r\u2028\u2029'''").then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression("r''' \n\u2028\u2029'''").then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression(
|
||||
"r'''\t\t \t\t \t\t \t \t \n\r\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression(
|
||||
"r'''\\\t\\\t \\ \\ \t\\\t \t \\\n\r\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression(
|
||||
"r'''\t\t \t\t \t\t \t \t \\\n\r\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\r\u2028\u2029"') ||
|
||||
generated.contains(r"'\r\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression(
|
||||
"r'''\\\t\\\t \\ \\ \t\\\t \\\r\n\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression(
|
||||
"r'''\\\t\\\t \\ \\ \t\\\t \\\r\u2028\u2029'''")
|
||||
.then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
await compileExpression("'\u2028\u2029'").then((String generated) {
|
||||
Expect.isTrue(generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"));
|
||||
Expect.isTrue(
|
||||
generated.contains(r'"\u2028\u2029"') ||
|
||||
generated.contains(r"'\u2028\u2029'"),
|
||||
generated);
|
||||
});
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
// TODO(johnniwinther): This test doesn't work with kernel.
|
||||
//print('--test from kernel----------------------------------------------');
|
||||
//await runTests(useKernel: true);
|
||||
print('--test from kernel----------------------------------------------');
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,22 +7,18 @@ import "package:async_helper/async_helper.dart";
|
|||
import '../compiler_helper.dart';
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
String code1 = await compileAll(
|
||||
r'''main() { return "${2}${true}${'a'}${3.14}"; }''',
|
||||
useKernel: useKernel);
|
||||
runTests() async {
|
||||
String code1 =
|
||||
await compileAll(r'''main() { return "${2}${true}${'a'}${3.14}"; }''');
|
||||
Expect.isTrue(code1.contains(r'2truea3.14'));
|
||||
|
||||
String code2 = await compileAll(
|
||||
r'''main() { return "foo ${new Object()}"; }''',
|
||||
useKernel: useKernel);
|
||||
String code2 =
|
||||
await compileAll(r'''main() { return "foo ${new Object()}"; }''');
|
||||
Expect.isFalse(code2.contains(r'$add'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -119,19 +119,17 @@ main() {
|
|||
var defOrCase3 = new RegExp(r"(default:|case 3):");
|
||||
var case3 = new RegExp(r"case 3:");
|
||||
|
||||
runTests({bool useKernel}) async {
|
||||
await compileAndDoNotMatch(SIMPLY_EMPTY, 'main', def, useKernel: useKernel);
|
||||
await compileAndDoNotMatch(TOTAL, 'main', defOrCase3, useKernel: useKernel);
|
||||
await compileAndDoNotMatch(OPTIMIZED, 'main', def, useKernel: useKernel);
|
||||
await compileAndMatch(LABEL, 'main', case3, useKernel: useKernel);
|
||||
await compileAndMatch(DEFLABEL, 'main', def, useKernel: useKernel);
|
||||
await compileAndMatch(EMPTYDEFLABEL, 'main', def, useKernel: useKernel);
|
||||
runTests() async {
|
||||
await compileAndDoNotMatch(SIMPLY_EMPTY, 'main', def);
|
||||
await compileAndDoNotMatch(TOTAL, 'main', defOrCase3);
|
||||
await compileAndDoNotMatch(OPTIMIZED, 'main', def);
|
||||
await compileAndMatch(LABEL, 'main', case3);
|
||||
await compileAndMatch(DEFLABEL, 'main', def);
|
||||
await compileAndMatch(EMPTYDEFLABEL, 'main', def);
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -61,12 +61,9 @@ foo(param1, param2) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
Future check(String test) {
|
||||
return compile(test,
|
||||
entry: 'foo',
|
||||
useKernel: useKernel,
|
||||
check: checkerForAbsentPresent(test));
|
||||
return compile(test, entry: 'foo', check: checkerForAbsentPresent(test));
|
||||
}
|
||||
|
||||
await check(TEST1);
|
||||
|
@ -77,9 +74,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,16 +26,14 @@ use(x) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST_ONE, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST_ONE);
|
||||
Expect.isFalse(generated.contains('Tarantula!'), "failed to remove 'foo'");
|
||||
Expect.isTrue(generated.contains('Coelacanth!'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,17 +26,15 @@ main() {
|
|||
""";
|
||||
|
||||
void main() {
|
||||
runTest({bool useKernel}) async {
|
||||
String generated = await compileAll(TEST, useKernel: useKernel);
|
||||
runTest() async {
|
||||
String generated = await compileAll(TEST);
|
||||
Expect.isTrue(generated.contains('return 42'));
|
||||
Expect.isTrue(generated.contains('return 54'));
|
||||
Expect.isFalse(generated.contains('return 68'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ sum(param0, param1) {
|
|||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compileAndMatchFuzzy(TEST_ONE, 'sum', r"\+\+x", useKernel: useKernel);
|
||||
await compileAndMatchFuzzy(TEST_ONE, 'sum', r"\+\+x");
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
|
|
|
@ -16,8 +16,7 @@ sum(param0, param1) {
|
|||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'sum', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'sum', check: (String generated) {
|
||||
RegExp regexp = new RegExp(getNumberTypeCheck('(param1|b)'));
|
||||
Expect.isTrue(
|
||||
regexp.hasMatch(generated), '$regexp not found in:\n$generated');
|
||||
|
|
|
@ -18,8 +18,7 @@ foo(j) {
|
|||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
// Test for absence of an illegal argument exception. This means that the
|
||||
// arguments are known to be integers.
|
||||
Expect.isFalse(generated.contains('iae'));
|
||||
|
|
|
@ -16,9 +16,8 @@ foo(j) {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTest({bool useKernel}) async {
|
||||
await compile(TEST_ONE, entry: 'foo', useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
runTest() async {
|
||||
await compile(TEST_ONE, entry: 'foo', check: (String generated) {
|
||||
// Test for absence of an illegal argument exception. This means that the
|
||||
// arguments are known to be integers.
|
||||
Expect.isFalse(generated.contains('iae'));
|
||||
|
@ -33,9 +32,7 @@ main() {
|
|||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTest(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTest(useKernel: true);
|
||||
await runTest();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,25 +35,23 @@ main() {
|
|||
""";
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
runTests() async {
|
||||
// Test that we know the type of captured, non-mutated variables.
|
||||
String generated1 = await compileAll(TEST1, useKernel: useKernel);
|
||||
String generated1 = await compileAll(TEST1);
|
||||
Expect.isTrue(generated1.contains('+ 87'));
|
||||
|
||||
// Test that we know the type of captured, mutated variables.
|
||||
String generated2 = await compileAll(TEST2, useKernel: useKernel);
|
||||
String generated2 = await compileAll(TEST2);
|
||||
Expect.isTrue(generated2.contains('+ 87'));
|
||||
|
||||
// Test that we know when types of a captured, mutated variable
|
||||
// conflict.
|
||||
String generated3 = await compileAll(TEST3, useKernel: useKernel);
|
||||
String generated3 = await compileAll(TEST3);
|
||||
Expect.isFalse(generated3.contains('+ 87'));
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -241,8 +241,8 @@ main(value) {
|
|||
BELOW_ZERO_CHECK,
|
||||
];
|
||||
|
||||
Future expect(String code, int kind, {bool useKernel}) {
|
||||
return compile(code, useKernel: useKernel, check: (String generated) {
|
||||
Future expect(String code, int kind) {
|
||||
return compile(code, check: (String generated) {
|
||||
switch (kind) {
|
||||
case REMOVED:
|
||||
Expect.isTrue(!generated.contains('ioore'));
|
||||
|
@ -285,6 +285,6 @@ Future expect(String code, int kind, {bool useKernel}) {
|
|||
|
||||
runTests({bool useKernel}) async {
|
||||
for (int i = 0; i < TESTS.length; i += 2) {
|
||||
await expect(TESTS[i], TESTS[i + 1], useKernel: useKernel);
|
||||
await expect(TESTS[i], TESTS[i + 1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ Future<String> compile(String code,
|
|||
bool analyzeAll: false,
|
||||
bool disableInlining: true,
|
||||
bool trustJSInteropTypeAnnotations: false,
|
||||
bool useKernel: false,
|
||||
void check(String generatedEntry),
|
||||
bool returnAll: false}) async {
|
||||
OutputCollector outputCollector = returnAll ? new OutputCollector() : null;
|
||||
|
@ -69,9 +68,6 @@ Future<String> compile(String code,
|
|||
if (trustJSInteropTypeAnnotations) {
|
||||
options.add(Flags.trustJSInteropTypeAnnotations);
|
||||
}
|
||||
if (!useKernel) {
|
||||
options.add(Flags.useOldFrontend);
|
||||
}
|
||||
if (disableInlining) {
|
||||
options.add(Flags.disableInlining);
|
||||
}
|
||||
|
@ -104,19 +100,13 @@ Future<String> compile(String code,
|
|||
}
|
||||
|
||||
Future<String> compileAll(String code,
|
||||
{Map<String, String> coreSource,
|
||||
bool disableInlining: true,
|
||||
{bool disableInlining: true,
|
||||
bool trustTypeAnnotations: false,
|
||||
bool minify: false,
|
||||
int expectedErrors,
|
||||
int expectedWarnings,
|
||||
bool useKernel: false}) async {
|
||||
int expectedWarnings}) async {
|
||||
OutputCollector outputCollector = new OutputCollector();
|
||||
DiagnosticCollector diagnosticCollector = new DiagnosticCollector();
|
||||
if (coreSource != null) {
|
||||
throw new UnsupportedError(
|
||||
'coreSource is not supported for useKernel=$useKernel');
|
||||
}
|
||||
List<String> options = <String>[];
|
||||
if (disableInlining) {
|
||||
options.add(Flags.disableInlining);
|
||||
|
@ -127,9 +117,6 @@ Future<String> compileAll(String code,
|
|||
if (minify) {
|
||||
options.add(Flags.minify);
|
||||
}
|
||||
if (!useKernel) {
|
||||
options.add(Flags.useOldFrontend);
|
||||
}
|
||||
CompilationResult result = await runCompiler(
|
||||
memorySourceFiles: {'main.dart': code},
|
||||
options: options,
|
||||
|
@ -173,19 +160,15 @@ void checkNumberOfMatches(Iterator it, int nb) {
|
|||
Expect.isFalse(hasNext, "Found more than $nb matches");
|
||||
}
|
||||
|
||||
Future compileAndMatch(String code, String entry, RegExp regexp,
|
||||
{bool useKernel: false}) {
|
||||
return compile(code, entry: entry, useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
Future compileAndMatch(String code, String entry, RegExp regexp) {
|
||||
return compile(code, entry: entry, check: (String generated) {
|
||||
Expect.isTrue(
|
||||
regexp.hasMatch(generated), '"$generated" does not match /$regexp/');
|
||||
});
|
||||
}
|
||||
|
||||
Future compileAndDoNotMatch(String code, String entry, RegExp regexp,
|
||||
{bool useKernel: false}) {
|
||||
return compile(code, entry: entry, useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
Future compileAndDoNotMatch(String code, String entry, RegExp regexp) {
|
||||
return compile(code, entry: entry, check: (String generated) {
|
||||
Expect.isFalse(
|
||||
regexp.hasMatch(generated), '"$generated" has a match in /$regexp/');
|
||||
});
|
||||
|
@ -195,22 +178,17 @@ int length(Link link) => link.isEmpty ? 0 : length(link.tail) + 1;
|
|||
|
||||
// Does a compile and then a match where every 'x' is replaced by something
|
||||
// that matches any variable, and every space is optional.
|
||||
Future compileAndMatchFuzzy(String code, String entry, String regexp,
|
||||
{bool useKernel: false}) {
|
||||
return compileAndMatchFuzzyHelper(code, entry, regexp,
|
||||
shouldMatch: true, useKernel: useKernel);
|
||||
Future compileAndMatchFuzzy(String code, String entry, String regexp) {
|
||||
return compileAndMatchFuzzyHelper(code, entry, regexp, shouldMatch: true);
|
||||
}
|
||||
|
||||
Future compileAndDoNotMatchFuzzy(String code, String entry, String regexp,
|
||||
{bool useKernel: false}) {
|
||||
return compileAndMatchFuzzyHelper(code, entry, regexp,
|
||||
shouldMatch: false, useKernel: useKernel);
|
||||
Future compileAndDoNotMatchFuzzy(String code, String entry, String regexp) {
|
||||
return compileAndMatchFuzzyHelper(code, entry, regexp, shouldMatch: false);
|
||||
}
|
||||
|
||||
Future compileAndMatchFuzzyHelper(String code, String entry, String regexp,
|
||||
{bool shouldMatch, bool useKernel: false}) {
|
||||
return compile(code, entry: entry, useKernel: useKernel,
|
||||
check: (String generated) {
|
||||
{bool shouldMatch}) {
|
||||
return compile(code, entry: entry, check: (String generated) {
|
||||
final xRe = new RegExp('\\bx\\b');
|
||||
regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)');
|
||||
final spaceRe = new RegExp('\\s+');
|
||||
|
|
|
@ -13,6 +13,7 @@ codegen/load_elimination_test: Pass, Slow
|
|||
codegen/logical_expression_test: Fail # Issue 17027
|
||||
codegen/side_effect_tdiv_regression_test: Fail # Issue 33050
|
||||
codegen/simple_function_subtype_test: Fail # simple_function_subtype_test is temporarily(?) disabled due to new method for building function type tests.
|
||||
codegen/string_escapes_test: Fail # Issue 33060
|
||||
deferred_loading/deferred_loading_test: Slow, Pass
|
||||
equivalence/id_equivalence1_test: Pass, Slow
|
||||
equivalence/id_equivalence2_test: Pass, Slow
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:async_helper/async_helper.dart';
|
|||
import 'package:expect/expect.dart';
|
||||
import '../compiler_helper.dart';
|
||||
|
||||
testUnreachableCrash({bool useKernel}) async {
|
||||
testUnreachableCrash() async {
|
||||
print("-- unreachable code doesn't crash the compiler --");
|
||||
// This test is a regression for Issue #24974
|
||||
String generated = await compile("""
|
||||
|
@ -19,13 +19,13 @@ testUnreachableCrash({bool useKernel}) async {
|
|||
external factory UniqueLongNameForTesting_A();
|
||||
}
|
||||
main() {}
|
||||
""", returnAll: true, useKernel: useKernel);
|
||||
""", returnAll: true);
|
||||
|
||||
// the code should not be included in the output either.
|
||||
Expect.isFalse(generated.contains("UniqueLongNameForTesting_A"));
|
||||
}
|
||||
|
||||
testTreeShakingJsInteropTypes({bool useKernel}) async {
|
||||
testTreeShakingJsInteropTypes() async {
|
||||
print('-- tree-shaking interop types --');
|
||||
String program = """
|
||||
import 'package:js/js.dart';
|
||||
|
@ -71,8 +71,7 @@ testTreeShakingJsInteropTypes({bool useKernel}) async {
|
|||
""";
|
||||
|
||||
print(' - no tree-shaking by default -');
|
||||
String generated1 =
|
||||
await compile(program, returnAll: true, useKernel: useKernel);
|
||||
String generated1 = await compile(program, returnAll: true);
|
||||
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_A"));
|
||||
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_D"));
|
||||
|
||||
|
@ -82,9 +81,7 @@ testTreeShakingJsInteropTypes({bool useKernel}) async {
|
|||
|
||||
print(' - tree-shake when using flag -');
|
||||
String generated2 = await compile(program,
|
||||
trustJSInteropTypeAnnotations: true,
|
||||
returnAll: true,
|
||||
useKernel: useKernel);
|
||||
trustJSInteropTypeAnnotations: true, returnAll: true);
|
||||
Expect.isTrue(generated2.contains("UniqueLongNameForTesting_A"));
|
||||
Expect.isTrue(generated2.contains("UniqueLongNameForTesting_D"));
|
||||
|
||||
|
@ -93,7 +90,7 @@ testTreeShakingJsInteropTypes({bool useKernel}) async {
|
|||
Expect.isFalse(generated2.contains("UniqueLongNameForTesting_E"));
|
||||
}
|
||||
|
||||
testTreeShakingNativeTypes({bool useKernel}) async {
|
||||
testTreeShakingNativeTypes() async {
|
||||
print('-- tree-shaking other native types --');
|
||||
|
||||
String program = """
|
||||
|
@ -116,8 +113,7 @@ testTreeShakingNativeTypes({bool useKernel}) async {
|
|||
""";
|
||||
|
||||
print(' - allocation effect of dynamic excludes native types -');
|
||||
String generated1 =
|
||||
await compile(program, returnAll: true, useKernel: useKernel);
|
||||
String generated1 = await compile(program, returnAll: true);
|
||||
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_A"));
|
||||
// any js-interop type could be allocated by `get x`
|
||||
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_B"));
|
||||
|
@ -127,9 +123,7 @@ testTreeShakingNativeTypes({bool useKernel}) async {
|
|||
print(' - allocation effect of dynamic excludes native types [flag] -');
|
||||
// Trusting types doesn't make a difference.
|
||||
String generated2 = await compile(program,
|
||||
trustJSInteropTypeAnnotations: true,
|
||||
returnAll: true,
|
||||
useKernel: useKernel);
|
||||
trustJSInteropTypeAnnotations: true, returnAll: true);
|
||||
Expect.isTrue(generated2.contains("UniqueLongNameForTesting_A"));
|
||||
Expect.isTrue(generated2.contains("UniqueLongNameForTesting_B"));
|
||||
Expect.isFalse(generated2.contains("HTMLAudioElement"));
|
||||
|
@ -149,8 +143,7 @@ testTreeShakingNativeTypes({bool useKernel}) async {
|
|||
}
|
||||
""";
|
||||
|
||||
String generated3 =
|
||||
await compile(program2, returnAll: true, useKernel: useKernel);
|
||||
String generated3 = await compile(program2, returnAll: true);
|
||||
Expect.isTrue(generated3.contains("UniqueLongNameForTesting_A"));
|
||||
Expect.isTrue(generated3.contains("HTMLAudioElement"));
|
||||
|
||||
|
@ -168,7 +161,7 @@ testTreeShakingNativeTypes({bool useKernel}) async {
|
|||
}
|
||||
""";
|
||||
|
||||
generated3 = await compile(program2, returnAll: true, useKernel: useKernel);
|
||||
generated3 = await compile(program2, returnAll: true);
|
||||
Expect.isTrue(generated3.contains("UniqueLongNameForTesting_A"));
|
||||
// This extra check is to make sure that we don't include HTMLAudioElement
|
||||
// just because of the is-check. It is optimized away in this case because
|
||||
|
@ -177,16 +170,14 @@ testTreeShakingNativeTypes({bool useKernel}) async {
|
|||
}
|
||||
|
||||
main() {
|
||||
runTests({bool useKernel}) async {
|
||||
await testUnreachableCrash(useKernel: useKernel);
|
||||
await testTreeShakingJsInteropTypes(useKernel: useKernel);
|
||||
await testTreeShakingNativeTypes(useKernel: useKernel);
|
||||
runTests() async {
|
||||
await testUnreachableCrash();
|
||||
await testTreeShakingJsInteropTypes();
|
||||
await testTreeShakingNativeTypes();
|
||||
}
|
||||
|
||||
asyncTest(() async {
|
||||
print('--test from ast---------------------------------------------------');
|
||||
await runTests(useKernel: false);
|
||||
print('--test from kernel------------------------------------------------');
|
||||
await runTests(useKernel: true);
|
||||
await runTests();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue