-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2js] 20 dart2js tests ported to nnbd #1.
Change-Id: I8cb1bb03655762669ac88775b5aee763e79c4b11 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152594 Reviewed-by: Stephen Adams <[email protected]> Commit-Queue: Joshua Litt <[email protected]>
- Loading branch information
1 parent
f4b19b8
commit 66c1b51
Showing
20 changed files
with
180 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// dart2jsOptions=-O0 | ||
|
||
// Regression test for passing type parameters through call-through stub. | ||
// | ||
// We use an abstract class with two implementations to avoid the optimizer | ||
// 'inlining' the call-through stub, so we are testing that the stub itself | ||
// passes through the type parameters. | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
abstract class AAA { | ||
dynamic get foo; | ||
} | ||
|
||
class B1 implements AAA { | ||
final dynamic foo; | ||
B1(this.foo); | ||
} | ||
|
||
class B2 implements AAA { | ||
final dynamic _arr; | ||
B2(foo) : _arr = [foo]; | ||
dynamic get foo => _arr.first; | ||
} | ||
|
||
class B3 implements AAA { | ||
final dynamic __foo; | ||
B3(this.__foo); | ||
dynamic get _foo => __foo; | ||
dynamic get foo => _foo; | ||
} | ||
|
||
@pragma('dart2js:noInline') | ||
test1<T>(AAA a, String expected) { | ||
// call-through getter 'foo' with one type argument. | ||
Expect.equals(expected, a.foo<T>()); | ||
} | ||
|
||
@pragma('dart2js:noInline') | ||
test2<U, V>(AAA a, String expected) { | ||
// call-through getter 'foo' with two type arguments. | ||
Expect.equals(expected, a.foo<U, V>()); | ||
} | ||
|
||
main() { | ||
test1<int>(B1(<P>() => '$P'), 'int'); | ||
test1<num>(B2(<Q>() => '$Q'), 'num'); | ||
test1<double>(B3(<R>() => '$R'), 'double'); | ||
|
||
test2<int, num>(B1(<A, B>() => '$A $B'), 'int num'); | ||
test2<num, int>(B2(<X, Y>() => '$X $Y'), 'num int'); | ||
test2<double, String>(B3(<C, D>() => '$C $D'), 'double String'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// This test is the same as 41449a_test.dart without forcing `-O0`. | ||
// | ||
// Regression test for passing type parameters through call-through stub. | ||
// | ||
// We use an abstract class with two implementations to avoid the optimizer | ||
// 'inlining' the call-through stub, so we are testing that the stub itself | ||
// passes through the type parameters. | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
abstract class AAA { | ||
dynamic get foo; | ||
} | ||
|
||
class B1 implements AAA { | ||
final dynamic foo; | ||
B1(this.foo); | ||
} | ||
|
||
class B2 implements AAA { | ||
final dynamic _arr; | ||
B2(foo) : _arr = [foo]; | ||
dynamic get foo => _arr.first; | ||
} | ||
|
||
class B3 implements AAA { | ||
final dynamic __foo; | ||
B3(this.__foo); | ||
dynamic get _foo => __foo; | ||
dynamic get foo => _foo; | ||
} | ||
|
||
@pragma('dart2js:noInline') | ||
test1<T>(AAA a, String expected) { | ||
// call-through getter 'foo' with one type argument. | ||
Expect.equals(expected, a.foo<T>()); | ||
} | ||
|
||
@pragma('dart2js:noInline') | ||
test2<U, V>(AAA a, String expected) { | ||
// call-through getter 'foo' with two type arguments. | ||
Expect.equals(expected, a.foo<U, V>()); | ||
} | ||
|
||
main() { | ||
test1<int>(B1(<P>() => '$P'), 'int'); | ||
test1<num>(B2(<Q>() => '$Q'), 'num'); | ||
test1<double>(B3(<R>() => '$R'), 'double'); | ||
|
||
test2<int, num>(B1(<A, B>() => '$A $B'), 'int num'); | ||
test2<num, int>(B2(<X, Y>() => '$X $Y'), 'num int'); | ||
test2<double, String>(B3(<C, D>() => '$C $D'), 'double String'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// dart2jsOptions=-O0 | ||
|
||
// Regression test for issue 42891. The root cause was a malformed SSA due to | ||
// generating a dynamic entry point argument test for an elided parameter | ||
// directly on the HLocalValue , which should only be an operand to HLocalGet | ||
// and HLocalSet. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
class CCC { | ||
void foo([num x = 123]) { | ||
try { | ||
Expect.equals(123, x); | ||
x = 0; | ||
} finally { | ||
Expect.equals(0, x); | ||
} | ||
} | ||
|
||
void bar([num x = 456]) { | ||
try { | ||
Expect.equals(123, x); | ||
x = 0; | ||
} finally { | ||
Expect.equals(0, x); | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
CCC().foo(); | ||
CCC().bar(123); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
|
||
@pragma('dart2js:disableFinal') | ||
void main() { | ||
String v = null; | ||
String? v = null; | ||
print('${v.hashCode}'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.