aboutsummaryrefslogtreecommitdiff
path: root/tests/issues
diff options
context:
space:
mode:
authorSebastian Pahnke <pahnke.sebastian@gmail.com>2024-12-28 08:51:54 +0100
committerSebastian Pahnke <pahnke.sebastian@gmail.com>2024-12-28 10:29:43 +0100
commit8a91e0bb19c013d0b088c90f3d1a09560dffac5c (patch)
tree1db79276d989eee41529b83e15220f7fdf202db1 /tests/issues
parentad99d20d292ab4708996c935315c36aef58796a8 (diff)
Add regression tests reproducing the issue
Diffstat (limited to 'tests/issues')
-rw-r--r--tests/issues/run.bat1
-rwxr-xr-xtests/issues/run.sh1
-rw-r--r--tests/issues/test_issue_4584.odin56
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/issues/run.bat b/tests/issues/run.bat
index dcea3d483..7ed43205d 100644
--- a/tests/issues/run.bat
+++ b/tests/issues/run.bat
@@ -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
diff --git a/tests/issues/run.sh b/tests/issues/run.sh
index c3bc00e24..54543980e 100755
--- a/tests/issues/run.sh
+++ b/tests/issues/run.sh
@@ -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
diff --git a/tests/issues/test_issue_4584.odin b/tests/issues/test_issue_4584.odin
new file mode 100644
index 000000000..b80ecb3d9
--- /dev/null
+++ b/tests/issues/test_issue_4584.odin
@@ -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))
+} \ No newline at end of file