fix optional-presence comparison
This commit is contained in:
+14
-2
@@ -13822,6 +13822,7 @@ enum_field_struct_and_contextual_anonymous_records_compile_and_run :: proc(t: ^t
|
||||
main_path := "/tmp/brolang-test-enum-field-struct/main.bro"
|
||||
output := "/tmp/brolang-test-enum-field-struct-output"
|
||||
text := `meta :: import "@std/meta"
|
||||
testing :: import "@std/testing"
|
||||
|
||||
TokenKind :: enum(u8) {
|
||||
ident = 3
|
||||
@@ -13854,6 +13855,8 @@ Generated func($T type) type {
|
||||
|
||||
GeneratedInt :: alias Generated(i32)
|
||||
ordered Names = {}
|
||||
static_none ?i32 :: none
|
||||
static_some ?i32 :: 1
|
||||
|
||||
Map func($E, $V type) type {
|
||||
match typeinfo!(E) {
|
||||
@@ -13894,6 +13897,8 @@ get func($E, $V type, map @Map(E, V), key E) ?V {
|
||||
|
||||
main func() i32 {
|
||||
_ = ordered
|
||||
if !$(static_none == none) or !$(none == static_none) or
|
||||
$(static_some == none) or $(none == static_some) { return 23 }
|
||||
inferred :: {x = 40, name = "bro"}
|
||||
if inferred.x != 40 or inferred.name.len != 3 { return 1 }
|
||||
direct Direct = {x = 7}
|
||||
@@ -13937,10 +13942,17 @@ main func() i32 {
|
||||
})
|
||||
if !map.present[0] or !map.present[1] or map.present[2] { return 9 }
|
||||
if map.values[0].len != 10 or map.values[1].len != 7 { return 18 }
|
||||
if get(TokenKind, []u8, &map, TokenKind.ident) |value| {
|
||||
ident :: get(TokenKind, []u8, &map, TokenKind.ident)
|
||||
if ident == none or none == ident { return 19 }
|
||||
if ident |value| {
|
||||
if value.len != 10 { return 19 }
|
||||
} else { return 20 }
|
||||
if get(TokenKind, []u8, &map, TokenKind.eof) |_| { return 21 }
|
||||
eof :: get(TokenKind, []u8, &map, TokenKind.eof)
|
||||
if eof != none or none != eof { return 21 }
|
||||
location testing.SourceLocation = {file = "test.bro", line = 1, column = 1}
|
||||
testing.expect_equal(none, eof, location) catch |_| { return 24 }
|
||||
testing.expect_equal(ident, ident, location) catch |_| { return 25 }
|
||||
if eof |_| { return 22 }
|
||||
return 0
|
||||
}
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user