about summary refs log tree commit diff stats
path: root/awk/rawk/scratch/debug_findindex.rawk
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/scratch/debug_findindex.rawk')
-rw-r--r--awk/rawk/scratch/debug_findindex.rawk38
1 files changed, 38 insertions, 0 deletions
diff --git a/awk/rawk/scratch/debug_findindex.rawk b/awk/rawk/scratch/debug_findindex.rawk
new file mode 100644
index 0000000..eabd13a
--- /dev/null
+++ b/awk/rawk/scratch/debug_findindex.rawk
@@ -0,0 +1,38 @@
+BEGIN {
+    print "=== Debug findIndex Test ==="
+}
+
+RAWK {
+    $is_positive_num = (x) -> {
+        return x > 0;
+    };
+}
+
+{
+    # Create test data
+    mixed[1] = -2;
+    mixed[2] = 0;
+    mixed[3] = 3;
+    mixed[4] = -5;
+    mixed[5] = 10;
+    
+    print "Test data:";
+    for (i = 1; i <= 5; i++) {
+        print "  mixed[" i "] = " mixed[i] " (positive: " is_positive_num(mixed[i]) ")";
+    }
+    
+    # Test findIndex
+    first_positive_index = findIndex("is_positive_num", mixed);
+    print "findIndex result:", first_positive_index;
+    
+    # Manual check
+    for (i = 1; i <= 5; i++) {
+        if (is_positive_num(mixed[i])) {
+            print "Manual check: first positive at index", i;
+            break;
+        }
+    }
+    
+    print "Test completed";
+    exit 0;
+} 
\ No newline at end of file