Add more tests and fix JS mode.

This commit is contained in:
treeform 2021-06-02 08:12:04 -07:00
parent 4441978b31
commit 8ad38bafb0
5 changed files with 25 additions and 13 deletions

View file

@ -14,3 +14,6 @@ jobs:
- uses: jiro4989/setup-nim-action@v1
- run: nimble test -y
- run: nimble test --gc:orc -y
- run: nimble test -y -d:vmathObjBased
- run: nimble test -y -d:vmathArrayBased
- run: nim js -r tests/test.nim

1
.gitignore vendored
View file

@ -4,5 +4,6 @@
!*.*
# normal ignores:
*.js
*.exe
nimcache

View file

@ -1,5 +1,7 @@
<img src="docs/banner.png">
![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg)
# VMath
![Github Actions](https://github.com/treeform/vmath/workflows/Github%20Actions/badge.svg)

View file

@ -1,4 +1,6 @@
## Based on the work of https://github.com/edin/raytracer
## MIT License
## Copyright (c) 2021 Edin Omeragic
import chroma, math, times, pixie, vmath, benchy

View file

@ -105,6 +105,7 @@ block:
assert isNan(float64(5.0e-324)) == false
block:
when not defined(js):
# Test vec2 cast.
var v = vec2(1.0, 2.0)
var a = cast[array[2, float32]](v)
@ -667,7 +668,7 @@ block:
doAssert q == quat(0, 0, 0, 0)
block:
# Test matrix to quat test.
# Test matrix and vector multiplication.
var a3 = mat3(
0.9659258723258972, -0.258819043636322, 0.0,
0.258819043636322, 0.9659258723258972, 0.0,
@ -679,12 +680,17 @@ block:
77.64571380615234, 0.0, 1.0
)
when not defined(js):
# TODO: Figure out why we loose soo much precision in js.
doAssert a3 * b3 ~= mat3(
1.0000, 0.0000, 0.0000,
0.0000, 1.0000, 0.0000,
50.0000, 50.0000, 1.0000
)
doAssert a3 * vec2(77.64571380615234, 0) ~= vec2(50.0, 50.0)
doAssert mat3(1, 2, 3, 4, 5, 6, 7, 8, 9) *
mat3(10, 20, 30, 40, 50, 60, 70, 80, 90) ~= mat3(
300.0000, 360.0000, 420.0000,
@ -692,8 +698,6 @@ block:
1020.0000, 1260.0000, 1500.0000
)
doAssert a3 * vec2(77.64571380615234, 0) ~= vec2(50.0, 50.0)
block:
# test quat and matrix lookat
doAssert lookAt(vec3(1, 2, 3), vec3(0, 0, 0)).quat ~=