about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_abs_fixed.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_abs_fixed.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_abs_fixed.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_abs_fixed.txt b/js/scripting-lang/scratch_tests/test_abs_fixed.txt
new file mode 100644
index 0000000..57e226d
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_abs_fixed.txt
@@ -0,0 +1,19 @@
+/* Test that abs -5 now works correctly */
+/* This was the original issue from PARSER_BUG_ANALYSIS.md */
+
+x : 5;
+abs : x -> when x is
+    x < 0 then -x
+    _ then x;
+
+/* Test 1: Function call with negative literal - THIS SHOULD WORK NOW */
+result1 : abs -5;  /* Should be apply(abs, negate(5)) = 5 */
+
+/* Test 2: Function call with negative variable - THIS SHOULD WORK NOW */
+result2 : abs -x;  /* Should be apply(abs, negate(x)) = 5 */
+
+/* Test 3: Function call with parenthesized negative expression - THIS SHOULD WORK NOW */
+result3 : abs (-x);  /* Should be apply(abs, negate(x)) = 5 */
+
+/* Test 4: Complex expression with negative argument - THIS SHOULD WORK NOW */
+result4 : abs -5 + 10;  /* Should be add(apply(abs, negate(5)), 10) = 15 */ 
\ No newline at end of file