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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// Tests issue #6068 https://github.com/odin-lang/Odin/issues/6068
package test_issues
import "core:testing"
@test
test_issue_6068 :: proc(t: ^testing.T) {
{
check_be : i128be = -1
check_le : i128le = -1
value := -1
reverse := i128be(value)
// test variable
testing.expect(t, i128be(value) == check_be)
testing.expect(t, i128be(-1) == check_be)
testing.expect(t, cast(i128be)value == check_be)
testing.expect(t, cast(i128be)-1 == check_be)
testing.expect(t, i128be(int(-1)) == check_be)
testing.expect(t, cast(i128be)int(-1) == check_be)
testing.expect(t, i128le(value) == check_le)
testing.expect(t, i128le(-1) == check_le)
testing.expect(t, cast(i128le)value == check_le)
testing.expect(t, cast(i128le)-1 == check_le)
testing.expect(t, i128le(int(-1)) == check_le)
testing.expect(t, cast(i128le)int(-1) == check_le)
testing.expect(t, i128le(reverse) == check_le)
testing.expect(t, cast(i128le)reverse == check_le)
// test literal
testing.expect(t, i128be(value) == -1)
testing.expect(t, i128be(-1) == -1)
testing.expect(t, cast(i128be)value == -1)
testing.expect(t, cast(i128be)-1 == -1)
testing.expect(t, i128be(int(-1)) == -1)
testing.expect(t, cast(i128be)int(-1) == -1)
testing.expect(t, i128le(value) == -1)
testing.expect(t, i128le(-1) == -1)
testing.expect(t, cast(i128le)value == -1)
testing.expect(t, cast(i128le)-1 == -1)
testing.expect(t, i128le(int(-1)) == -1)
testing.expect(t, cast(i128le)int(-1) == -1)
testing.expect(t, i128le(reverse) == -1)
testing.expect(t, cast(i128le)reverse == -1)
}
// NOTE(ske): [llvm_backend_const.cpp:lb_big_int_to_llvm]
// floats behaved wonky when I tested because I forgot to sign extend whole
// rop so I added more tests here to be safe
{
check_be : f64be = -1.234
check_le : f64le = -1.234
value : f64 = -1.234
reverse := f64be(value)
// test variable
testing.expect(t, f64be(value) == check_be)
testing.expect(t, f64be(-1.234) == check_be)
testing.expect(t, cast(f64be)value == check_be)
testing.expect(t, cast(f64be)-1.234 == check_be)
testing.expect(t, f64be(int(-1.234)) == check_be)
testing.expect(t, cast(f64be)int(-1.234) == check_be)
testing.expect(t, f64le(value) == check_le)
testing.expect(t, f64le(-1.234) == check_le)
testing.expect(t, cast(f64le)value == check_le)
testing.expect(t, cast(f64le)-1.234 == check_le)
testing.expect(t, f64le(int(-1.234)) == check_le)
testing.expect(t, cast(f64le)int(-1.234) == check_le)
testing.expect(t, f64le(reverse) == check_le)
testing.expect(t, cast(f64le)reverse == check_le)
// test literal
testing.expect(t, f64be(value) == -1.234)
testing.expect(t, f64be(-1.234) == -1.234)
testing.expect(t, cast(f64be)value == -1.234)
testing.expect(t, cast(f64be)-1.234 == -1.234)
testing.expect(t, f64be(int(-1.234)) == -1.234)
testing.expect(t, cast(f64be)int(-1.234) == -1.234)
testing.expect(t, f64le(value) == -1.234)
testing.expect(t, f64le(-1.234) == -1.234)
testing.expect(t, cast(f64le)value == -1.234)
testing.expect(t, cast(f64le)-1.234 == -1.234)
testing.expect(t, f64le(int(-1.234)) == -1.234)
testing.expect(t, cast(f64le)int(-1.234) == -1.234)
testing.expect(t, f64le(reverse) == -1.234)
testing.expect(t, cast(f64le)reverse == -1.234)
}
testing.expect(t, i64be(-1) + i64be(1) == 0)
testing.expect(t, i64le(-1) + i64le(i64be(1)) == 0)
testing.expect(t, i64be(-7) * i64be(7) == -49)
}
|