Skip to content

Commit

Permalink
#1243 Expect.isTrue() is returned back for type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Dec 15, 2021
1 parent 0f05f10 commit dc7bae1
Show file tree
Hide file tree
Showing 58 changed files with 173 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Language/Classes/Constructors/implicit_constructor_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ typedef CAlias = C;

main() {
CAlias c = new CAlias();
Expect.isTrue(c is C);
checkType(checkIs<C>, true, c);
Expect.equals(null, c.x);

CAlias c2 = new C();
Expect.isTrue(c2 is C);
checkType(checkIs<C>, true, c2);
Expect.equals(null, c2.x);
}
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/extends_clause_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class A {}
class B extends A {}

main() {
Expect.isTrue(new B() is A);
checkType(checkIs<A>, true, B());
}
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/extends_clause_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ typedef AAlias = A;
class B extends AAlias {}

main() {
Expect.isTrue(new B() is A);
checkType(checkIs<A>, true, B());
}
1 change: 1 addition & 0 deletions Language/Classes/Superclasses/no_extends_clause_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class A {}

main() {
A a = new A();
Expect.isTrue(a is Object);
checkType(checkIs<Object>, true, a);
}
3 changes: 3 additions & 0 deletions Language/Classes/Superclasses/transition_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class D extends C {}

main() {
D d = new D();
Expect.isTrue(d is B);
Expect.isTrue(d is A);
Expect.isTrue(d is Object);
checkType(checkIs<B>, true, d);
checkType(checkIs<A>, true, d);
checkType(checkIs<Object>, true, d);
Expand Down
3 changes: 3 additions & 0 deletions Language/Classes/Superclasses/transition_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class D extends CAlias {}

main() {
D d = new D();
Expect.isTrue(d is C);
Expect.isTrue(d is B);
Expect.isTrue(d is A);
checkType(checkIs<C>, true, d);
checkType(checkIs<B>, true, d);
checkType(checkIs<A>, true, d);
Expand Down
4 changes: 4 additions & 0 deletions Language/Classes/Superinterfaces/syntax_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class C extends B implements IC, ID {}

main() {
C c = new C();
Expect.isTrue(c is IA);
Expect.isTrue(c is IB);
Expect.isTrue(c is IC);
Expect.isTrue(c is ID);
checkType(checkIs<IA>, true, c);
checkType(checkIs<IB>, true, c);
checkType(checkIs<IC>, true, c);
Expand Down
4 changes: 4 additions & 0 deletions Language/Classes/Superinterfaces/syntax_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class C extends B implements ICAlias, IDAlias {}

main() {
C c = new C();
Expect.isTrue(c is IA);
Expect.isTrue(c is IB);
Expect.isTrue(c is IC);
Expect.isTrue(c is ID);
checkType(checkIs<IA>, true, c);
checkType(checkIs<IB>, true, c);
checkType(checkIs<IC>, true, c);
Expand Down
6 changes: 6 additions & 0 deletions Language/Classes/implements_clause_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ main() {
B b = new B();
C c = new C();
D d = new D();
Expect.isTrue(b is I1);
Expect.isTrue(c is I1);
Expect.isTrue(c is I2);
Expect.isTrue(d is I1);
Expect.isTrue(d is I2);
Expect.isTrue(d is I3);
checkType(checkIs<I1>, true, b);
checkType(checkIs<I1>, true, c);
checkType(checkIs<I2>, true, c);
Expand Down
6 changes: 6 additions & 0 deletions Language/Classes/implements_clause_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ main() {
B b = new B();
C c = new C();
D d = new D();
Expect.isTrue(b is I1);
Expect.isTrue(c is I1);
Expect.isTrue(c is I2);
Expect.isTrue(d is I1);
Expect.isTrue(d is I2);
Expect.isTrue(d is I3);
checkType(checkIs<I1>, true, b);
checkType(checkIs<I1>, true, c);
checkType(checkIs<I2>, true, c);
Expand Down
2 changes: 2 additions & 0 deletions Language/Classes/implicit_interface_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class D implements C {}

main() {
var b = new B();
Expect.isTrue(b is A);
checkType(checkIs<A>, true, b);

var d = new D();
Expect.isTrue(d is C);
checkType(checkIs<C>, true, d);
}
4 changes: 3 additions & 1 deletion Language/Enums/declaration_equivalent_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
/// @description Checks that type of each member of an enum is this enum type
/// @author [email protected]

import "../../Utils/expect.dart";

enum E {a, b, c}

main() {
Expect.isTrue(E.a is E);
Expect.isTrue(E.b is E);
Expect.isTrue(E.c is E);
checkType(checkIs<E>, true, E.a);
checkType(checkIs<E>, true, E.b);
checkType(checkIs<E>, true, E.c);
Expand Down
2 changes: 1 addition & 1 deletion Language/Enums/declaration_equivalent_t06.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/// @description Checks enum values type
/// @author [email protected]

import "../../Utils/expect.dart";

enum E {a, b, c}

main() {
Expect.isTrue(E.values is List<E>);
checkType(checkIs<List<E>>, true, E.values);
}
3 changes: 2 additions & 1 deletion Language/Expressions/Booleans/class_bool_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
/// bool.
/// @author msyabro

import '../../../Utils/expect.dart';

main() {
Expect.isTrue(false is bool);
Expect.isTrue(true is bool);
checkType(checkIs<bool>, true, false);
checkType(checkIs<bool>, true, true);
}
2 changes: 2 additions & 0 deletions Language/Expressions/Booleans/runtime_type_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import '../../../Utils/expect.dart';

main() {
Expect.isTrue(true.runtimeType is Type);
checkType(checkIs<Type>, true, true.runtimeType);
Expect.isTrue(true.runtimeType == bool);
Expect.isTrue(false.runtimeType is Type);
checkType(checkIs<Type>, true, false.runtimeType);
Expect.isTrue(false.runtimeType == bool);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/constant_list_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ import '../../../Utils/expect.dart';
final constList = const [const ["hello", "world"]];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/constant_map_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ import '../../../Utils/expect.dart';
final constMap = const {"a" : 1, "b" : 2};

main() {
Expect.isTrue(constMap is Map);
checkType(checkIs<Map>, true, constMap);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/equals_expression_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/identical_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const c2 = Map;
const d = C;

main() {
Expect.isTrue(a is Type);
Expect.isTrue(b is Type);
Expect.isTrue(c is Type);
Expect.isTrue(c2 is Type);
Expect.isTrue(d is Type);
checkType(checkIs<Type>, true, a);
checkType(checkIs<Type>, true, b);
checkType(checkIs<Type>, true, c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const a = F;
const b = FF;

main() {
Expect.isTrue(a is Type);
Expect.isTrue(b is Type);
checkType(checkIs<Type>, true, a);
checkType(checkIs<Type>, true, b);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/literal_boolean_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/literal_number_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/literal_number_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
3 changes: 3 additions & 0 deletions Language/Expressions/Constants/literal_string_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ final constListConcatenation = const [
];

main() {
Expect.isTrue(constList is List);
Expect.isTrue(constListInterpolation is List);
Expect.isTrue(constListConcatenation is List);
checkType(checkIs<List>, true, constList);
checkType(checkIs<List>, true, constListInterpolation);
checkType(checkIs<List>, true, constListConcatenation);
Expand Down
1 change: 1 addition & 0 deletions Language/Expressions/Constants/math_operators_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/math_operators_t07.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ import '../../../Utils/expect.dart';
const m = "ab" + "cd";

main() {
Expect.isTrue(m is String);
checkType(checkIs<String>, true, m);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/math_operators_t08.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ final constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/null_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ import '../../../Utils/expect.dart';
final constList = const [null];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ const constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/static_constant_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ const constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/static_constant_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ const constList = const [
];

main() {
Expect.isTrue(constList is List);
checkType(checkIs<List>, true, constList);
}
1 change: 1 addition & 0 deletions Language/Expressions/Constants/ternary_operator_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ const list = const [
];

main() {
Expect.isTrue(list is List);
checkType(checkIs<List>, true, list);
}
4 changes: 4 additions & 0 deletions Language/Expressions/Constants/top_level_function_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const c = clib.F;
const d = clib.B.M;

main() {
Expect.isTrue(a is Function);
Expect.isTrue(b is Function);
Expect.isTrue(c is Function);
Expect.isTrue(d is Function);
checkType(checkIs<Function>, true, a);
checkType(checkIs<Function>, true, b);
checkType(checkIs<Function>, true, c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import '../../../Utils/expect.dart';

main() {
Expect.isTrue(() {} is Function);
Expect.isTrue((() => 1) is Function);
Expect.isTrue(((p1, p2) {}) is Function);
Expect.isTrue(((p1, [int? p2]) {}) is Function);
Expect.isTrue(((p1, {int p2: 1}) {}) is Function);
checkType(checkIs<Function>, true, () {});
checkType(checkIs<Function>, true, (() => 1));
checkType(checkIs<Function>, true, ((p1, p2) {}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import '../../../Utils/expect.dart';
main() {
var d = 1.0 as double?;
var x1 = d ?? 2.0;
Expect.isTrue(x1 is double);
checkType(checkIs<double>, true, x1);

var x2 = null ?? 2.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class D {
}

main() {
Expect.isTrue(const A.name() is A);
Expect.isTrue(const B.name(1, 2) is B);
Expect.isTrue(const C.name("") is C);
Expect.isTrue(const D.name(null, p2: 1) is D);
checkType(checkIs<A>, true, const A.name());
checkType(checkIs<B>, true, const B.name(1, 2));
checkType(checkIs<C>, true, const C.name(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class D {
}

main() {
Expect.isTrue(const A() is A);
Expect.isTrue(const B(0) is B);
Expect.isTrue(const C(p2: true, p1: "") is C);
Expect.isTrue(const D(0, 0) is D);
checkType(checkIs<A>, true, const A());
checkType(checkIs<B>, true, const B(0));
checkType(checkIs<C>, true, const C(p2: true, p1: ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class B <T extends A> {
A? t;
B(): t = new A() {
Expect.isNotNull(t);
Expect.isTrue(t is A);
checkType(checkIs<A>, true, t);
}
}
Expand Down
4 changes: 4 additions & 0 deletions Language/Expressions/Instance_Creation/New/execution_t08.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class D {
}

main() {
Expect.isTrue(new A() is A);
Expect.isTrue(new B(1, 2) is B);
Expect.isTrue(new C(null, null) is C);
Expect.isTrue(new D.name() is D);
checkType(checkIs<A>, true, new A());
checkType(checkIs<B>, true, new B(1, 2));
checkType(checkIs<C>, true, new C(null, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class B <T extends A> {

B.redirected(): t = new A() {
Expect.isNotNull(t);
Expect.isTrue(t is A);
checkType(checkIs<A>, true, t);
}

Expand Down
Loading

0 comments on commit dc7bae1

Please sign in to comment.