diff --git a/client/main.c b/client/main.c index 73fff0eb..220992ea 100644 --- a/client/main.c +++ b/client/main.c @@ -105,7 +105,7 @@ void debug_repl(FILE *in, FILE *out) { } int main() { - printf("Super cool interpreter v0.0\n"); + printf("GST v0.0 repl\nCopyright 2017 Calvin Rose\n"); debug_repl(stdin, stdout); return 0; } diff --git a/core/ds.c b/core/ds.c index ffb1eff7..e8fb8d0d 100644 --- a/core/ds.c +++ b/core/ds.c @@ -248,8 +248,7 @@ GstValue gst_object_remove(Gst * vm, GstObject *o, GstValue key) { } } -/* Put a value into the dictionary. Returns 1 if successful, 0 if out of memory. - * The VM pointer is needed for memory allocation. */ +/* Put a value into the dictionary. */ void gst_object_put(Gst *vm, GstObject *o, GstValue key, GstValue value) { GstBucket *bucket, *previous; uint32_t index = gst_hash(key) % o->capacity; diff --git a/gsttests/basic.gst b/gsttests/basic.gst new file mode 100644 index 00000000..96e699f9 --- /dev/null +++ b/gsttests/basic.gst @@ -0,0 +1,11 @@ +# Define assert +(: assert (fn [x e] (if x x (do (print e) (exit 1))))) + +# Basic Math +(assert (= 10 (+ 1 2 3 4), "addition") +(assert (= -8 (- 1 2 3 4), "subtraction") +(assert (= 24 (* 1 2 3 4), "multiplication") +(assert (= 0.1 (/ 1 10), "division") + +# All good +(exit 0) diff --git a/libs/stl.gst b/libs/stl.gst index 81084c1e..8b137891 100644 --- a/libs/stl.gst +++ b/libs/stl.gst @@ -1,2 +1 @@ -# The standard library -(fn + [...args] + diff --git a/sample.gst b/sample.gst deleted file mode 100644 index 9c90d4a3..00000000 --- a/sample.gst +++ /dev/null @@ -1,12 +0,0 @@ -(do - (:= a (set-class {} {"call" (fn [self a] (set self "last" a) (print self) self)})) - (a 1) - (a 2) - (a 3) -) - -# Run call-for-each test - -(call-for-each print 1 2 3 4) - -(call-for-each (fn [a] (print a "hi")) 1 2 3 45)