diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf9e75b..c734050 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,6 +59,7 @@ functionaltest("function-mutable-capture") functionaltest("map") functionaltest("deconstruct") functionaltest("shadowing") +functionaltest("mathops") install(TARGETS apfl DESTINATION lib) install(TARGETS apfl-bin DESTINATION bin) diff --git a/src/functional-tests/mathops.at b/src/functional-tests/mathops.at new file mode 100644 index 0000000..176cae8 --- /dev/null +++ b/src/functional-tests/mathops.at @@ -0,0 +1,17 @@ +===== script ===== +print (+ 1 2) +print (+ 1 2 3 4) +print (- 1) +print (- 1 2) +print (- 1 2 3) +print (* 1 2 3) +print (/ 1 2 4) + +===== output ===== +3 +10 +-1 +-1 +-4 +6 +0.125 diff --git a/src/globals.c b/src/globals.c index c510808..55172ff 100644 --- a/src/globals.c +++ b/src/globals.c @@ -101,7 +101,7 @@ impl_eq(apfl_ctx ctx) apfl_get_list_member_by_index(ctx, 0, 0); \ apfl_number num = apfl_get_number(ctx, -1); \ if (len == 1) { \ - single(num); \ + apfl_push_number(ctx, single(num)); \ return; \ } \ \