-
Notifications
You must be signed in to change notification settings - Fork 28
#1399. [Records] Subtyping tests for records added #1412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
LanguageFeatures/Subtyping/dynamic/generated/records_arguments_binding_A01_t01.dart
This file contains hidden or 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,125 @@ | ||
// Copyright (c) 2018, 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 We say that a type T0 is a subtype of a type T1 (written | ||
/// T0 <: T1) when: | ||
/// A record type A is a subtype of record type B iff they have same shape and | ||
/// the types of all fields of A are subtypes of the corresponding field types | ||
/// of B | ||
/// | ||
/// @description Check that if type T0 is a record with the same shape that T1 | ||
/// and the types of all fields of T0 is subtype of of the corresponding field | ||
/// types of T1 then T0 is subtype of T1. Check positional fields only | ||
/// @author [email protected] | ||
/// | ||
/// @description Check that if type T0 is a subtype of a type T1, then instance | ||
/// of T0 can be used as an argument of type T1 | ||
/// @author [email protected] | ||
/// | ||
/// This test is generated from records_A01.dart and | ||
/// arguments_binding_x01.dart. | ||
/// Don't modify it. If you want to change this test, change one of the files | ||
/// above and then run generator.dart to regenerate the tests. | ||
|
||
|
||
import '../../utils/common.dart'; | ||
|
||
// SharedOptions=--enable-experiment=records | ||
|
||
(int x, double y, String) t0Instance = (42, 3.14, ""); | ||
(num, num z, String?) t1Instance = (0, 0, null); | ||
eernstg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const t1Default = (0, 0, null); | ||
|
||
|
||
|
||
namedArgumentsFunc1((num, num, String?) t1, {(num, num, String?) t2 = t1Default}) {} | ||
positionalArgumentsFunc1((num, num, String?) t1, [(num, num, String?) t2 = t1Default]) {} | ||
|
||
namedArgumentsFunc2<X>(X t1, {required X t2}) {} | ||
|
||
class ArgumentsBindingClass { | ||
ArgumentsBindingClass((num, num, String?) t1) {} | ||
|
||
ArgumentsBindingClass.named((num, num, String?) t1, {(num, num, String?) t2 = t1Default}) {} | ||
ArgumentsBindingClass.positional((num, num, String?) t1, [(num, num, String?) t2 = t1Default]) {} | ||
|
||
factory ArgumentsBindingClass.fNamed((num, num, String?) t1, {(num, num, String?) t2 = t1Default}) { | ||
return new ArgumentsBindingClass.named(t1, t2: t2); | ||
} | ||
factory ArgumentsBindingClass.fPositional((num, num, String?) t1, [(num, num, String?) t2 = t1Default]) { | ||
return new ArgumentsBindingClass.positional(t1, t2); | ||
} | ||
|
||
static namedArgumentsStaticMethod((num, num, String?) t1, {(num, num, String?) t2 = t1Default}) {} | ||
static positionalArgumentsStaticMethod((num, num, String?) t1, [(num, num, String?) t2 = t1Default]) {} | ||
|
||
namedArgumentsMethod((num, num, String?) t1, {(num, num, String?) t2 = t1Default}) {} | ||
positionalArgumentsMethod((num, num, String?) t1, [(num, num, String?) t2 = t1Default]) {} | ||
|
||
set testSetter((num, num, String?) val) {} | ||
} | ||
|
||
class ArgumentsBindingGen<X> { | ||
ArgumentsBindingGen(X t1) {} | ||
|
||
ArgumentsBindingGen.named(X t1, {required X t2}) {} | ||
|
||
factory ArgumentsBindingGen.fNamed(X t1, {required X t2}) { | ||
return new ArgumentsBindingGen.named(t1, t2: t2); | ||
} | ||
|
||
namedArgumentsMethod(X t1, {required X t2}) {} | ||
|
||
set testSetter(X val) {} | ||
} | ||
|
||
main() { | ||
// test functions | ||
namedArgumentsFunc1(forgetType(t0Instance), t2: forgetType(t0Instance)); | ||
positionalArgumentsFunc1(forgetType(t0Instance), forgetType(t0Instance)); | ||
|
||
// test class constructors | ||
ArgumentsBindingClass instance1 = | ||
new ArgumentsBindingClass(forgetType(t0Instance)); | ||
instance1 = new ArgumentsBindingClass.fNamed(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
instance1 = new ArgumentsBindingClass.named(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
instance1 = new ArgumentsBindingClass.positional(forgetType(t0Instance), | ||
forgetType(t0Instance)); | ||
|
||
// tests methods and setters | ||
instance1.namedArgumentsMethod(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
instance1.positionalArgumentsMethod(forgetType(t0Instance), | ||
forgetType(t0Instance)); | ||
instance1.testSetter = forgetType(t0Instance); | ||
|
||
// test static methods | ||
ArgumentsBindingClass.namedArgumentsStaticMethod(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
ArgumentsBindingClass.positionalArgumentsStaticMethod( | ||
forgetType(t0Instance), forgetType(t0Instance)); | ||
|
||
// Test type parameters | ||
|
||
//# <-- NotGenericFunctionType | ||
// test generic functions | ||
namedArgumentsFunc2<(num, num, String?)>(forgetType(t0Instance), t2: forgetType(t0Instance)); | ||
|
||
// test generic class constructors | ||
ArgumentsBindingGen<(num, num, String?)> instance2 = | ||
new ArgumentsBindingGen<(num, num, String?)>(forgetType(t0Instance)); | ||
instance2 = new ArgumentsBindingGen<(num, num, String?)>.fNamed(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
instance2 = new ArgumentsBindingGen<(num, num, String?)>.named(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
|
||
// test generic class methods and setters | ||
instance2.namedArgumentsMethod(forgetType(t0Instance), | ||
t2: forgetType(t0Instance)); | ||
instance2.testSetter = forgetType(t0Instance); | ||
//# --> | ||
} | ||
eernstg marked this conversation as resolved.
Show resolved
Hide resolved
|
129 changes: 129 additions & 0 deletions
129
LanguageFeatures/Subtyping/dynamic/generated/records_arguments_binding_A01_t02.dart
This file contains hidden or 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,129 @@ | ||
// Copyright (c) 2018, 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 We say that a type T0 is a subtype of a type T1 (written | ||
/// T0 <: T1) when: | ||
/// A record type A is a subtype of record type B iff they have same shape and | ||
/// the types of all fields of A are subtypes of the corresponding field types | ||
/// of B | ||
/// | ||
/// @description Check that if type T0 is a record with the same shape that T1 | ||
/// and the types of all fields of T0 is subtype of of the corresponding field | ||
/// types of T1 then T0 is subtype of T1. Check positional fields only | ||
/// @author [email protected] | ||
/// | ||
/// @description Check that if type T0 is a subtype of a type T1, then instance | ||
/// of T0 can be used as an argument of type T1. Test superclass members | ||
/// @author [email protected] | ||
/// | ||
/// This test is generated from records_A01.dart and | ||
/// arguments_binding_x02.dart. | ||
/// Don't modify it. If you want to change this test, change one of the files | ||
/// above and then run generator.dart to regenerate the tests. | ||
|
||
|
||
import '../../utils/common.dart'; | ||
|
||
// SharedOptions=--enable-experiment=records | ||
|
||
(int x, double y, String) t0Instance = (42, 3.14, ""); | ||
(num, num z, String?) t1Instance = (0, 0, null); | ||
|
||
const t1Default = (0, 0, null); | ||
|
||
|
||
|
||
|
||
class ArgumentsBindingSuper1_t02 { | ||
(num, num, String?) m; | ||
|
||
ArgumentsBindingSuper1_t02((num, num, String?) value): m = value {} | ||
ArgumentsBindingSuper1_t02.named((num, num, String?) value, {(num, num, String?) val2 = t1Default}): m = value {} | ||
ArgumentsBindingSuper1_t02.positional((num, num, String?) value, [(num, num, String?) val2 = t1Default]): m = value {} | ||
ArgumentsBindingSuper1_t02.short(this.m); | ||
|
||
void superTest((num, num, String?) val) {} | ||
void superTestPositioned((num, num, String?) val, [(num, num, String?) val2 = t1Default]) {} | ||
void superTestNamed((num, num, String?) val, {(num, num, String?) val2 = t1Default}) {} | ||
(num, num, String?) get superGetter => m; | ||
void set superSetter((num, num, String?) val) {} | ||
} | ||
|
||
class ArgumentsBinding1_t02 extends ArgumentsBindingSuper1_t02 { | ||
ArgumentsBinding1_t02(dynamic t1) : super(t1) {} | ||
ArgumentsBinding1_t02.c2(dynamic t1, dynamic t2) : super.named(t1, val2: t2) {} | ||
ArgumentsBinding1_t02.c3(dynamic t1) : super.positional(t1) {} | ||
ArgumentsBinding1_t02.c4(dynamic t1, dynamic t2) : super.positional(t1, t2) {} | ||
ArgumentsBinding1_t02.c5(dynamic t1) : super.short(t1) {} | ||
|
||
test(dynamic t1, dynamic t2) { | ||
superTest(t1); | ||
superTestPositioned(t1); | ||
superTestPositioned(t2, t1); | ||
superTestNamed(t1); | ||
superTestNamed(t2, val2: t1); | ||
superSetter = t1; | ||
m = t1; | ||
superGetter; | ||
} | ||
} | ||
|
||
class ArgumentsBindingSuper2_t02<X> { | ||
X m; | ||
|
||
ArgumentsBindingSuper2_t02(X value): m = value {} | ||
ArgumentsBindingSuper2_t02.named(X value, {required X val2}):m = value {} | ||
ArgumentsBindingSuper2_t02.short(this.m); | ||
|
||
void superTest(X val) {} | ||
void superTestNamed(X val, {required X val2}) {} | ||
X get superGetter => m; | ||
void set superSetter(X val) {} | ||
} | ||
|
||
class ArgumentsBinding2_t02<X> extends ArgumentsBindingSuper2_t02<X> { | ||
ArgumentsBinding2_t02(X t1) : super(t1) {} | ||
ArgumentsBinding2_t02.c2(dynamic t1, dynamic t2) : super.named(t1, val2: t2) {} | ||
ArgumentsBinding2_t02.c5(dynamic t1) : super.short(t1) {} | ||
|
||
test(X t1, X t2) { | ||
superTest(t1); | ||
superTestNamed(t2, val2: t1); | ||
superSetter = t1; | ||
m = t1; | ||
superGetter; | ||
} | ||
} | ||
|
||
main() { | ||
ArgumentsBinding1_t02 c1 = new ArgumentsBinding1_t02(forgetType(t0Instance)); | ||
c1 = new ArgumentsBinding1_t02.c2(t1Instance, forgetType(t0Instance)); | ||
eernstg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
c1 = new ArgumentsBinding1_t02.c3(forgetType(t0Instance)); | ||
c1 = new ArgumentsBinding1_t02.c4(t1Instance, forgetType(t0Instance)); | ||
c1 = new ArgumentsBinding1_t02.c5(forgetType(t0Instance)); | ||
|
||
c1.test(forgetType(t0Instance), t1Instance); | ||
c1.superTest(forgetType(t0Instance)); | ||
c1.superTestPositioned(forgetType(t0Instance)); | ||
c1.superTestPositioned(t1Instance, forgetType(t0Instance)); | ||
c1.superTestNamed(forgetType(t0Instance)); | ||
c1.superTestNamed(t1Instance, val2: forgetType(t0Instance)); | ||
c1.superSetter = forgetType(t0Instance); | ||
c1.superGetter; | ||
|
||
// Test type parameters | ||
|
||
//# <-- NotGenericFunctionType | ||
ArgumentsBinding2_t02<(num, num, String?)> c2 = | ||
new ArgumentsBinding2_t02<(num, num, String?)>(forgetType(t0Instance)); | ||
c2 = new ArgumentsBinding2_t02<(num, num, String?)>.c2(t1Instance, forgetType(t0Instance)); | ||
c2 = new ArgumentsBinding2_t02<(num, num, String?)>.c5(forgetType(t0Instance)); | ||
|
||
c2.test(forgetType(t0Instance), t1Instance); | ||
c2.superTest(forgetType(t0Instance)); | ||
c2.superTestNamed(t1Instance, val2: forgetType(t0Instance)); | ||
c2.superSetter = forgetType(t0Instance); | ||
c2.superGetter; | ||
//# --> | ||
} |
98 changes: 98 additions & 0 deletions
98
LanguageFeatures/Subtyping/dynamic/generated/records_arguments_binding_A01_t03.dart
This file contains hidden or 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,98 @@ | ||
// Copyright (c) 2018, 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 We say that a type T0 is a subtype of a type T1 (written | ||
/// T0 <: T1) when: | ||
/// A record type A is a subtype of record type B iff they have same shape and | ||
/// the types of all fields of A are subtypes of the corresponding field types | ||
/// of B | ||
/// | ||
/// @description Check that if type T0 is a record with the same shape that T1 | ||
/// and the types of all fields of T0 is subtype of of the corresponding field | ||
/// types of T1 then T0 is subtype of T1. Check positional fields only | ||
/// @author [email protected] | ||
/// | ||
/// @description Check that if type T0 is a subtype of a type T1, then instance | ||
/// of T0 can be used as an argument of type T1. Test mixin members | ||
/// @author [email protected] | ||
/// | ||
/// This test is generated from records_A01.dart and | ||
/// arguments_binding_x03.dart. | ||
/// Don't modify it. If you want to change this test, change one of the files | ||
/// above and then run generator.dart to regenerate the tests. | ||
|
||
|
||
import '../../utils/common.dart'; | ||
|
||
// SharedOptions=--enable-experiment=records | ||
|
||
(int x, double y, String) t0Instance = (42, 3.14, ""); | ||
(num, num z, String?) t1Instance = (0, 0, null); | ||
|
||
const t1Default = (0, 0, null); | ||
|
||
|
||
|
||
|
||
class ArgumentsBindingMixin1_t03 { | ||
(num, num, String?) m = t1Default; | ||
|
||
void superTest((num, num, String?) val) {} | ||
void superTestPositioned((num, num, String?) val, [(num, num, String?) val2 = t1Default]) {} | ||
void superTestNamed((num, num, String?) val, {(num, num, String?) val2 = t1Default}) {} | ||
(num, num, String?) get superGetter => m; | ||
void set superSetter((num, num, String?) val) {} | ||
} | ||
|
||
class ArgumentsBinding1_t03 extends Object with ArgumentsBindingMixin1_t03 { | ||
|
||
test(dynamic t1, dynamic t2) { | ||
superTest(t1); | ||
superTestPositioned(t1); | ||
superTestPositioned(t2, t1); | ||
superTestNamed(t1); | ||
superTestNamed(t2, val2: t1); | ||
superSetter = t1; | ||
m = t1; | ||
superGetter; | ||
} | ||
} | ||
|
||
class ArgumentsBindingMixin2_t03<X> { | ||
void superTest(X val) {} | ||
void superTestNamed(X val, {required X val2}) {} | ||
void set superSetter(X val) {} | ||
} | ||
|
||
class ArgumentsBinding2_t03<X> extends Object with ArgumentsBindingMixin2_t03<X> { | ||
|
||
test(dynamic t1, dynamic t2) { | ||
superTest(t1); | ||
superTestNamed(t2, val2: t1); | ||
superSetter = t1; | ||
} | ||
} | ||
|
||
main() { | ||
ArgumentsBinding1_t03 c1 = new ArgumentsBinding1_t03(); | ||
|
||
c1.test(forgetType(t0Instance), t1Instance); | ||
c1.superTest(forgetType(t0Instance)); | ||
c1.superTestPositioned(forgetType(t0Instance)); | ||
c1.superTestPositioned(t1Instance, forgetType(t0Instance)); | ||
c1.superTestNamed(forgetType(t0Instance)); | ||
c1.superTestNamed(t1Instance, val2: forgetType(t0Instance)); | ||
c1.superSetter = forgetType(t0Instance); | ||
c1.superGetter; | ||
|
||
// Test type parameters | ||
|
||
//# <-- NotGenericFunctionType | ||
ArgumentsBinding2_t03<(num, num, String?)> c2 = new ArgumentsBinding2_t03<(num, num, String?)>(); | ||
c2.test(forgetType(t0Instance), t1Instance); | ||
c2.superTest(forgetType(t0Instance)); | ||
c2.superTestNamed(t1Instance, val2: forgetType(t0Instance)); | ||
c2.superSetter = forgetType(t0Instance); | ||
//# --> | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.