Skip to content

Commit 1fbc564

Browse files
committed
Add to tests/internal
Turn repro code into a proper test, and delete superfluous files from Odin root.
1 parent 8410871 commit 1fbc564

File tree

4 files changed

+34
-259
lines changed

4 files changed

+34
-259
lines changed

minimal_test.odin

Lines changed: 0 additions & 31 deletions
This file was deleted.

real_test.odin

Lines changed: 0 additions & 227 deletions
This file was deleted.

src/types.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ gb_internal bool is_type_unsigned(Type *t) {
12491249
return (t->Basic.flags & BasicFlag_Unsigned) != 0;
12501250
}
12511251
if (t->kind == Type_Enum) {
1252-
// TODO(slowhei): Is an enum's base type guaranteed to be TypeKind::Basic? Even if its backing type is implicitly int?
12531252
return (t->Enum.base_type->Basic.flags & BasicFlag_Unsigned) != 0;
12541253
}
12551254
return false;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package test_internal
2+
3+
import "core:testing"
4+
5+
@test
6+
test_comparisons_5408 :: proc(t: ^testing.T) {
7+
// See: https://github.com/odin-lang/Odin/pull/5408
8+
test_proc :: proc(lhs: $T, rhs: T) -> bool {
9+
return lhs > rhs
10+
}
11+
12+
Test_Enum :: enum u32 {
13+
SMALL_VALUE = 0xFF,
14+
BIG_VALUE = 0xFF00_0000, // negative if interpreted as i32
15+
}
16+
17+
testing.expect_value(t, test_proc(Test_Enum.SMALL_VALUE, Test_Enum.BIG_VALUE), false)
18+
testing.expect_value(t, test_proc(Test_Enum(0xF), Test_Enum.BIG_VALUE), false)
19+
testing.expect_value(t, test_proc(Test_Enum(0xF), Test_Enum(0xF000_0000)), false)
20+
testing.expect_value(t, test_proc(Test_Enum.SMALL_VALUE, max(Test_Enum)), false)
21+
testing.expect_value(t, test_proc(Test_Enum(0xF), max(Test_Enum)), false)
22+
}
23+
24+
test_signedness :: proc(t: ^testing.T) {
25+
{
26+
a, b := i16(32767), i16(0)
27+
testing.expect_value(t, a > b, true)
28+
}
29+
30+
{
31+
a, b := u16(65535), u16(0)
32+
testing.expect_value(t, a > b, true)
33+
}
34+
}

0 commit comments

Comments
 (0)