mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-25 22:41:34 +00:00
add regression test for incorrect offset_of
This commit is contained in:
@@ -40,6 +40,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
|
||||
..\..\..\odin test ..\test_issue_6753.odin %COMMON% || exit /b
|
||||
..\..\..\odin check ..\test_issue_6874.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b
|
||||
..\..\..\odin check ..\test_issue_6979.odin -no-entry-point %COMMON% || exit /b
|
||||
..\..\..\odin test ..\test_issue_7008.odin %COMMON% || exit /b
|
||||
..\..\..\odin check ..\test_issue_7012.odin -no-entry-point %COMMON% || exit /b
|
||||
..\..\..\odin build ..\test_issue_7037.odin %COMMON% -o:none || exit /b
|
||||
..\..\..\odin build ..\test_issue_7188.odin %COMMON% || exit /b
|
||||
|
||||
@@ -88,6 +88,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
$ODIN check ../test_issue_6979.odin -no-entry-point $COMMON_CHECK
|
||||
$ODIN test ../test_issue_7008.odin $COMMON
|
||||
$ODIN check ../test_issue_7012.odin -no-entry-point $COMMON_CHECK
|
||||
$ODIN build ../test_issue_7037.odin $COMMON -o:none
|
||||
$ODIN test ../test_issue_7356.odin $COMMON
|
||||
|
||||
27
tests/issues/test_issue_7008.odin
Normal file
27
tests/issues/test_issue_7008.odin
Normal file
@@ -0,0 +1,27 @@
|
||||
// Tests issue #7008 https://github.com/odin-lang/Odin/issues/7008
|
||||
package test_issues
|
||||
|
||||
import "core:testing"
|
||||
import "core:slice"
|
||||
|
||||
Bar :: struct {
|
||||
p: ^Foo,
|
||||
}
|
||||
|
||||
Maybe_Bar :: union {
|
||||
Bar,
|
||||
}
|
||||
|
||||
Foo :: struct {
|
||||
bar: Maybe_Bar,
|
||||
value: byte,
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_offset_of_is_correct :: proc(t: ^testing.T) {
|
||||
foo: Foo
|
||||
foo.value = 42
|
||||
|
||||
bytes := slice.bytes_from_ptr(&foo, size_of(Foo))
|
||||
testing.expect_value(t, bytes[offset_of(foo.value)], 42)
|
||||
}
|
||||
Reference in New Issue
Block a user