-
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.
#1243 Runtime type checks added to Spread collections tests
- Loading branch information
sgrekhov
committed
Dec 23, 2021
1 parent
a2335af
commit fe659c4
Showing
32 changed files
with
281 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,13 @@ | |
/// @description Checks that empty collection is a map. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
Expect.isTrue({} is Map); | ||
Expect.runtimeIsType<Map>({}); | ||
|
||
dynamic map = {}; | ||
Expect.isTrue(map is Map); | ||
Expect.runtimeIsType<Map>(map); | ||
} |
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
/// @description Checks that [setOrMapLiteral] has one type argument, it's a set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
|
@@ -25,7 +24,9 @@ main() { | |
|
||
var res1 = <int>{...aSet}; | ||
Expect.isTrue(res1 is Set); | ||
Expect.runtimeIsType<Set>(res1); | ||
|
||
var res2 = <Object>{...aList}; | ||
Expect.isTrue(res2 is Set); | ||
Expect.runtimeIsType<Object>(res2); | ||
} |
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
/// @description Checks that [setOrMapLiteral] has one type argument, it's a set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
|
@@ -25,7 +24,9 @@ main() { | |
|
||
var res1 = <int>{...?aSet}; | ||
Expect.isTrue(res1 is Set); | ||
Expect.runtimeIsType<Set>(res1); | ||
|
||
var res2 = <Object>{...?aList}; | ||
Expect.isTrue(res2 is Set); | ||
Expect.runtimeIsType<Set>(res2); | ||
} |
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
/// @description Checks that [setOrMapLiteral] has one type argument, it's a set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
|
@@ -26,9 +25,11 @@ main() { | |
|
||
var res1 = <int>{...aSet}; | ||
Expect.isTrue(res1 is Set); | ||
Expect.runtimeIsType<Set>(res1); | ||
|
||
var res2 = <Object>{...aList}; | ||
Expect.isTrue(res2 is Set); | ||
Expect.runtimeIsType<Set>(res2); | ||
|
||
var res3; | ||
Expect.throws(() => res3 = <int>{...aMap}); | ||
|
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 |
---|---|---|
|
@@ -23,4 +23,5 @@ main() { | |
|
||
var res = <int, int>{...aMap}; | ||
Expect.isTrue(res is Map); | ||
Expect.runtimeIsType<Map>(res); | ||
} |
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 |
---|---|---|
|
@@ -23,4 +23,5 @@ main() { | |
|
||
var res = <int, int>{...?aMap}; | ||
Expect.isTrue(res is Map); | ||
Expect.runtimeIsType<Map>(res); | ||
} |
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// or set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
const l1 = []; | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// constant list or set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A { | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// element is not potentially constant list or set. | ||
/// @author [email protected] | ||
|
||
class MyClass { | ||
final String a; | ||
const MyClass(Object o) : a = o as 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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// element is not potentially constant list or set. | ||
/// @author [email protected] | ||
|
||
class A { | ||
const A(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// constant list or set. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
Set emptyset = {}; | ||
|
@@ -29,7 +28,6 @@ class MyClass { | |
const MyClass(Object o) : a = o as String; | ||
} | ||
|
||
|
||
main() { | ||
const Set s1 = {...(A() is B ? [12345] : [])}; | ||
Expect.setEquals(emptyset, s1); | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// element is not a potentially constant list or set. | ||
/// @author [email protected] | ||
|
||
class A { | ||
const A(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// constant map. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A { | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
/// constant map. | ||
/// @author [email protected] | ||
|
||
class MyClass { | ||
const MyClass(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant list or set or [null]. | ||
/// @author [email protected] | ||
|
||
class MyClass { | ||
final String a; | ||
const MyClass(Object o) : a = o as 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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant list or set or [null]. | ||
/// @author [email protected] | ||
|
||
class A { | ||
const A(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant list or set. | ||
/// @author [email protected] | ||
|
||
class A { | ||
const A(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant list or set. | ||
/// @author [email protected] | ||
|
||
class MyClass { | ||
final String a; | ||
const MyClass(Object o) : a = o as 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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant map or [null]. | ||
/// @author [email protected] | ||
|
||
class A { | ||
const A(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
/// potentially constant map or null. | ||
/// @author [email protected] | ||
|
||
class MyClass { | ||
final String a; | ||
const MyClass(Object o) : a = o as 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 |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
/// @description Checks that instance of [List<E>] is created for a list literal | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
|
@@ -30,4 +29,8 @@ main() { | |
Expect.isTrue(<String>[...?list3] is List<String>); | ||
Expect.isTrue(<int>[...?list3] is List<int>); | ||
Expect.isTrue([...list4] is List<Object?>); | ||
Expect.runtimeIsType<List<String>>(<String>[...list2, "123"]); | ||
Expect.runtimeIsType<List<String>>(<String>[...?list3]); | ||
Expect.runtimeIsType<List<int>>(<int>[...?list3] ); | ||
Expect.runtimeIsType<List<Object?>>([...list4]); | ||
} |
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 |
---|---|---|
|
@@ -13,11 +13,12 @@ | |
/// three or more type arguments. | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
main() { | ||
var a; | ||
Expect.isTrue(<int>{} is Set); | ||
Expect.isTrue(<int, int>{} is Map); | ||
Expect.runtimeIsType<Set>(<int>{}); | ||
Expect.runtimeIsType<Map>(<int, int>{}); | ||
} |
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
/// the list literal | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A {} | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
/// the set literal | ||
/// @author [email protected] | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
class A {} | ||
|
@@ -30,25 +29,32 @@ main() { | |
|
||
Set set1 = <int>{2, 7, ...int_list, 4}; | ||
Expect.isTrue(set1 is Set<int>); | ||
Expect.runtimeIsType<Set<int>>(set1); | ||
|
||
Set set2 = <A>{a, ...a_list}; | ||
Expect.isTrue(set2 is Set<A>); | ||
Expect.runtimeIsType<Set<A>>(set2); | ||
|
||
Set set3 = <A>{a, ...b_list}; | ||
Expect.isTrue(set3 is Set<A>); | ||
Expect.runtimeIsType<Set<A>>(set3); | ||
|
||
Set set4 = <A>{a, c, ...c_list, b}; | ||
Expect.isTrue(set4 is Set<A>); | ||
Expect.runtimeIsType<Set<A>>(set4); | ||
|
||
Set set5 = <A>{a, b, c, ...c_list, new B(), ...a_list, ...b_list, new A()}; | ||
Expect.isTrue(set5 is Set<A>); | ||
Expect.runtimeIsType<Set<A>>(set5); | ||
|
||
Set set6 = <B>{b, ...b_list, c, ...c_list}; | ||
Expect.isTrue(set6 is Set<B>); | ||
Expect.runtimeIsType<Set<B>>(set6); | ||
|
||
Set set7 = {123, "123", null, a, ...a_list, ...?b_list, c, b, ...?c_list, | ||
...str_list, ...int_list, null, 1499, []}; | ||
Expect.isTrue(set7 is Set<Object?>); | ||
Expect.runtimeIsType<Set<Object?>>(set7); | ||
|
||
Set set8; | ||
Expect.throws(() => set8 = <int>{...str_list}); | ||
|
Oops, something went wrong.