Skip to content

#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 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

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);
//# -->
}
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));
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;
//# -->
}
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);
//# -->
}
Loading