about summary refs log tree commit diff stats
path: root/awk/rawk/tests/test_basic.rawk
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/tests/test_basic.rawk')
-rw-r--r--awk/rawk/tests/test_basic.rawk41
1 files changed, 41 insertions, 0 deletions
diff --git a/awk/rawk/tests/test_basic.rawk b/awk/rawk/tests/test_basic.rawk
new file mode 100644
index 0000000..bb3470c
--- /dev/null
+++ b/awk/rawk/tests/test_basic.rawk
@@ -0,0 +1,41 @@
+BEGIN {
+    print "=== Basic Block-Based rawk Tests ==="
+}
+
+RAWK {
+    $add = (x, y) -> {
+        return x + y;
+    };
+    
+    $multiply = (a, b) -> {
+        return a * b;
+    };
+    
+    $greet = (name) -> {
+        return "Hello, " name "!";
+    };
+    
+    $is_positive_num = (num) -> {
+        return num > 0;
+    };
+}
+
+{
+    # Test basic arithmetic
+    result1 = add(5, 3);
+    expect_equal(result1, 8, "add(5, 3) should return 8");
+    
+    result2 = multiply(4, 7);
+    expect_equal(result2, 28, "multiply(4, 7) should return 28");
+    
+    # Test string functions
+    greeting = greet("World");
+    expect_equal(greeting, "Hello, World!", "greet('World') should return 'Hello, World!'");
+    
+    # Test boolean functions
+    expect_true(is_positive_num(10), "is_positive_num(10) should return true");
+    expect_false(is_positive_num(-5), "is_positive_num(-5) should return false");
+    
+    print "All basic tests passed!";
+    exit 0;
+} 
\ No newline at end of file