added a warning if using an invalid key type
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 17:04:51 +0000 (11:04 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 17:04:51 +0000 (11:04 -0600)
core/map.onyx
runtests.sh

index d1f2e533261374ddd9bb54e37435f7c18135663a..de7264b5f277953fd8b1141a0508174fab4de45d 100644 (file)
@@ -114,7 +114,7 @@ MapLookupResult :: struct {
 lookup :: proc (use map: ^Map($K, $V), key: K) -> MapLookupResult {
     lr := MapLookupResult.{};
 
-    hash := hash_function(key);
+    hash := hash_function(key); // You cannot use this type for the key, unless you add an overload.
 
     lr.hash_index = hash % hashes.count;
     lr.entry_index = hashes[lr.hash_index];
index 4c01bce5be27df9c0ab5f1f9acc3448530ce9c97..92ea4fa404e96dd820530e38cb1dee33ad99215b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-success=1
+failed=0
 for test_file in ./tests/*.onyx ; do
        filename=$(basename -- "$test_file")
        name="${filename%.*}"
@@ -9,20 +9,20 @@ for test_file in ./tests/*.onyx ; do
 
        if ! ./onyx "$test_file" -o "./tests/$name.wasm" >/dev/null; then
                echo "❌ Failed to compile $name.onyx."
-               success=0
+               failed=1
                continue
        fi
        
        if ! node onyxcmd.js "./tests/$name.wasm" > ./tmpoutput; then
                echo "❌ Failed to run $name.onyx."
-               success=0
+               failed=1
                continue
        fi
 
        if ! diff ./tmpoutput "./tests/$name" >/dev/null; then
                echo "❌ Test output did not match."
                diff ./tmpoutput "./tests/$name"
-               success=0
+               # failed=0
                continue
        fi
 
@@ -30,5 +30,7 @@ for test_file in ./tests/*.onyx ; do
 done
 rm ./tmpoutput
 
-([ $success = 1 ] && echo "✔ All tests passed.") \
+([ $failed = 0 ] && echo "✔ All tests passed.") \
                                  || echo "❌ Some tests failed."
+
+exit $failed
\ No newline at end of file