-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1087. More function tear-offs tests added
- Loading branch information
sgrekhov
committed
Jun 9, 2021
1 parent
47c7a9b
commit 4d770fd
Showing
13 changed files
with
512 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t01.dart
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,40 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of generic instance method | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class C { | ||
var x; | ||
C() { | ||
x = instanceMethod<int>; | ||
} | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
Expect.equals(42, c.x(42)); | ||
dynamic d1 = -42; | ||
Expect.isTrue(c.x(d1) is int); | ||
Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic | ||
dynamic d2 = 3.14; | ||
Expect.throws(() {c.x(d2);}); | ||
} |
40 changes: 40 additions & 0 deletions
40
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t02.dart
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,40 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of generic instance method | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
class C { | ||
var x; | ||
C() { | ||
x = instanceMethod<int>; | ||
} | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
c.x(3.14); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
c.x<double>(42); | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
40 changes: 40 additions & 0 deletions
40
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t03.dart
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,40 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of generic instance method including 'this' | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class C { | ||
var x; | ||
C() { | ||
x = this.instanceMethod<int>; | ||
} | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
Expect.equals(42, c.x(42)); | ||
dynamic d1 = -42; | ||
Expect.isTrue(c.x(d1) is int); | ||
Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic | ||
dynamic d2 = 3.14; | ||
Expect.throws(() {c.x(d2);}); | ||
} |
40 changes: 40 additions & 0 deletions
40
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t04.dart
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,40 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of generic instance method including 'this' | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
class C { | ||
var x; | ||
C() { | ||
x = this.instanceMethod<int>; | ||
} | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
c.x(3.14); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
c.x<double>(42); | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
43 changes: 43 additions & 0 deletions
43
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t05.dart
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,43 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of inherited generic instance method | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A { | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
class C extends A { | ||
var x; | ||
C() { | ||
x = instanceMethod<int>; | ||
} | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
Expect.equals(42, c.x(42)); | ||
dynamic d1 = -42; | ||
Expect.isTrue(c.x(d1) is int); | ||
Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic | ||
dynamic d2 = 3.14; | ||
Expect.throws(() {c.x(d2);}); | ||
} |
43 changes: 43 additions & 0 deletions
43
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t06.dart
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,43 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of inherited generic instance method | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
class A { | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
class C extends A { | ||
var x; | ||
C() { | ||
x = instanceMethod<int>; | ||
} | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
c.x(3.14); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
c.x<double>(42); | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
44 changes: 44 additions & 0 deletions
44
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t07.dart
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,44 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of inherited generic instance method including | ||
/// 'this' | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A { | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
class C extends A { | ||
var x; | ||
C() { | ||
x = this.instanceMethod<int>; | ||
} | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
Expect.equals(42, c.x(42)); | ||
dynamic d1 = -42; | ||
Expect.isTrue(c.x(d1) is int); | ||
Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic | ||
dynamic d2 = 3.14; | ||
Expect.throws(() {c.x(d2);}); | ||
} |
44 changes: 44 additions & 0 deletions
44
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t08.dart
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,44 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of inherited generic instance method including | ||
/// 'this' | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
class A { | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
class C extends A { | ||
var x; | ||
C() { | ||
x = this.instanceMethod<int>; | ||
} | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
c.x(3.14); | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
c.x<double>(42); | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
44 changes: 44 additions & 0 deletions
44
LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t09.dart
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,44 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
/// @assertion These grammar changes allows type parameters without following | ||
/// parenthesized arguments in places where we previously did not allow them. | ||
/// For example, this means that <typeArguments> becomes a selector by itself, | ||
/// not just followed by arguments. | ||
// | ||
// It applies to instance methods as well as local, static and top-level | ||
// function declarations. For instance methods, it applies to references of the | ||
// form | ||
// | ||
// instanceMethod<int> (with implicit this), | ||
// object.instanceMethod<int> (including this) and super.instanceMethod<int>. | ||
/// | ||
/// @description Checks tear-off of inherited generic instance method including | ||
/// 'super' | ||
/// @author sgrekhov@unipro.ru | ||
// SharedOptions=--enable-experiment=constructor-tearoffs | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A { | ||
T instanceMethod<T>(T t) => t; | ||
} | ||
|
||
class C extends A { | ||
var x; | ||
C() { | ||
x = super.instanceMethod<int>; | ||
} | ||
} | ||
|
||
main() { | ||
C c = new C(); | ||
Expect.equals(42, c.x(42)); | ||
dynamic d1 = -42; | ||
Expect.isTrue(c.x(d1) is int); | ||
Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic | ||
dynamic d2 = 3.14; | ||
Expect.throws(() {c.x(d2);}); | ||
} |
Oops, something went wrong.