/
mar.tyr
72 lines (70 loc) · 1.33 KB
/
mar.tyr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* tests correctness of switch class expressions
*
* note to self: for switch class, *all* implicit conversions on the target are
* performed
*/
type T {
test "basic class" {
var r = ""
switch class r {
if String false
if StringLiteral true
else false
}
}
test "basic class inferred" {
var r = ""
switch r {
if String false
if StringLiteral true
else false
}
}
test "null" {
var r : String = null
switch class r {
if String false
if StringLiteral false
if Null true
else false
}
}
// note to self: null get's a special rule stating it is only an instance of
// Null and will pick else otherwise
test "null implicit" {
var r : String = null
switch class r {
if String false
if StringLiteral false
else true
}
}
// note: order does not matter
test "null order" {
var r : String = null
switch class r {
if Null true
if String false
if StringLiteral false
else false
}
}
test "not null" {
var r : String = null
r = ""
switch class r {
if String false
if StringLiteral true
if Null false
else false
}
}
test "just null" {
var r : String = null
switch class r {
if Null {return true}
else false
}
}
}