mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-11 02:19:30 +00:00
add test for #6874
This commit is contained in:
@@ -36,6 +36,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
|
||||
..\..\..\odin test ..\test_pr_6470.odin -define:TEST_EXPECT_FAILURE=true %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b
|
||||
..\..\..\odin test ..\test_pr_6476.odin %COMMON% || exit /b
|
||||
..\..\..\odin check ..\test_issue_6484.odin -no-entry-point %COMMON% || exit /b
|
||||
..\..\..\odin check ..\test_issue_6874.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
@@ -73,6 +73,12 @@ else
|
||||
exit 1
|
||||
fi
|
||||
$ODIN check ../test_issue_6484.odin -no-entry-point $COMMON
|
||||
if [[ $($ODIN check ../test_issue_6874.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 1 ]] ; then
|
||||
echo "SUCCESSFUL 1/1"
|
||||
else
|
||||
echo "SUCCESSFUL 0/1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +x
|
||||
|
||||
|
||||
35
tests/issues/test_issue_6874.odin
Normal file
35
tests/issues/test_issue_6874.odin
Normal file
@@ -0,0 +1,35 @@
|
||||
// Test for issue #6874 https://github.com/odin-lang/Odin/issues/6874
|
||||
|
||||
package test_issues
|
||||
|
||||
import "core:fmt"
|
||||
|
||||
PersonData :: struct {
|
||||
health: int,
|
||||
age: int,
|
||||
}
|
||||
|
||||
MyUnion :: union {
|
||||
f32,
|
||||
int,
|
||||
PersonData,
|
||||
}
|
||||
|
||||
change_union_data :: proc(data: MyUnion) {
|
||||
switch &v in data {
|
||||
case int:
|
||||
v = 10
|
||||
case f32:
|
||||
fmt.println("f32")
|
||||
case PersonData:
|
||||
fmt.println("PersonData")
|
||||
fmt.println(v)
|
||||
}
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
val: MyUnion = int(12)
|
||||
fmt.printfln("Before the call: %v", val)
|
||||
change_union_data(val)
|
||||
fmt.printfln("After the call: %v", val)
|
||||
}
|
||||
Reference in New Issue
Block a user