Add regression tests reproducing the issue

This commit is contained in:
Sebastian Pahnke
2024-12-28 08:51:54 +01:00
parent ad99d20d29
commit 8a91e0bb19
3 changed files with 58 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style
..\..\..\odin test ..\test_issue_2637.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_2666.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_4210.odin %COMMON% || exit /b
..\..\..\odin test ..\test_issue_4584.odin %COMMON% || exit /b
@echo off

View File

@@ -17,6 +17,7 @@ $ODIN test ../test_issue_2615.odin $COMMON
$ODIN test ../test_issue_2637.odin $COMMON
$ODIN test ../test_issue_2666.odin $COMMON
$ODIN test ../test_issue_4210.odin $COMMON
$ODIN test ../test_issue_4584.odin $COMMON
if [[ $($ODIN build ../test_issue_2395.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
echo "SUCCESSFUL 1/1"
else

View File

@@ -0,0 +1,56 @@
// Tests issue #4584 https://github.com/odin-lang/Odin/issues/4584
package test_issues
import "core:testing"
import "core:math/linalg"
@test
test_adjugate_2x2 :: proc(t: ^testing.T) {
m := matrix[2,2]int {
-3, 2,
-1, 0,
}
expected := matrix[2,2]int {
0, -2,
1, -3,
}
testing.expect_value(t, linalg.adjugate(m), expected)
testing.expect_value(t, linalg.determinant(m), 2)
testing.expect_value(t, linalg.adjugate(m) * m, 2 * linalg.identity(matrix[2,2]int))
}
@test
test_adjugate_3x3 :: proc(t: ^testing.T) {
m := matrix[3,3]int {
-3, 2, -5,
-1, 0, -2,
3, -4, 1,
}
expected := matrix[3,3]int {
-8, 18, -4,
-5, 12, -1,
4, -6, 2,
}
testing.expect_value(t, linalg.adjugate(m), expected)
testing.expect_value(t, linalg.determinant(m), -6)
testing.expect_value(t, linalg.adjugate(m) * m, -6 * linalg.identity(matrix[3,3]int))
}
@test
test_adjugate_4x4 :: proc(t: ^testing.T) {
m := matrix[4,4]int {
-3, 2, -5, 1,
-1, 0, -2, 2,
3, -4, 1, 3,
4, 5, 6, 7,
}
expected := matrix[4,4]int {
-144, 266, -92, -16,
57, 92, -5, -16,
105, -142, 55, 2,
33, -96, 9, -6,
}
testing.expect_value(t, linalg.adjugate(m), expected)
testing.expect_value(t, linalg.determinant(m), -174)
testing.expect_value(t, linalg.adjugate(m) * m, -174 * linalg.identity(matrix[4,4]int))
}