about summary refs log tree commit diff stats
path: root/awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk')
-rw-r--r--awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk61
1 files changed, 61 insertions, 0 deletions
diff --git a/awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk b/awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk
new file mode 100644
index 0000000..b5f6970
--- /dev/null
+++ b/awk/rawk/scratch/tests_old/stdlib/test_predicates_simple.rawk
@@ -0,0 +1,61 @@
+# Simple test for rawk predicate functions
+
+BEGIN {
+    print "=== Simple Predicate Functions Test ==="
+    print ""
+    
+    # Test basic type checking
+    print "is_number(42): " is_number(42)
+    print "is_number(\"hello\"): " is_number("hello")
+    print "is_string(\"hello\"): " is_string("hello")
+    print "is_string(42): " is_string(42)
+    print "is_empty(\"\"): " is_empty("")
+    print "is_empty(0): " is_empty(0)
+    print "is_empty(\"hello\"): " is_empty("hello")
+    
+    # Test numeric predicates
+    print ""
+    print "is_positive(42): " is_positive(42)
+    print "is_positive(-5): " is_positive(-5)
+    print "is_negative(-42): " is_negative(-42)
+    print "is_negative(5): " is_negative(5)
+    print "is_zero(0): " is_zero(0)
+    print "is_zero(42): " is_zero(42)
+    print "is_integer(42): " is_integer(42)
+    print "is_integer(3.14): " is_integer(3.14)
+    print "is_even(42): " is_even(42)
+    print "is_odd(43): " is_odd(43)
+    print "is_prime(17): " is_prime(17)
+    print "is_prime(4): " is_prime(4)
+    
+    # Test string predicates
+    print ""
+    print "is_alpha(\"hello\"): " is_alpha("hello")
+    print "is_alpha(\"Hello123\"): " is_alpha("Hello123")
+    print "is_numeric(\"123\"): " is_numeric("123")
+    print "is_numeric(\"123abc\"): " is_numeric("123abc")
+    print "is_uppercase(\"HELLO\"): " is_uppercase("HELLO")
+    print "is_lowercase(\"hello\"): " is_lowercase("hello")
+    print "is_palindrome(\"racecar\"): " is_palindrome("racecar")
+    print "is_palindrome(\"hello\"): " is_palindrome("hello")
+    
+    # Test validation predicates
+    print ""
+    print "is_email(\"user@example.com\"): " is_email("user@example.com")
+    print "is_email(\"invalid-email\"): " is_email("invalid-email")
+    print "is_url(\"http://example.com\"): " is_url("http://example.com")
+    print "is_url(\"example.com\"): " is_url("example.com")
+    print "is_ipv4(\"192.168.1.1\"): " is_ipv4("192.168.1.1")
+    print "is_ipv4(\"256.1.2.3\"): " is_ipv4("256.1.2.3")
+    
+    # Test string length
+    print ""
+    print "is_length(\"hello\", 5): " is_length("hello", 5)
+    print "is_length(\"hello\", 3): " is_length("hello", 3)
+    
+    print ""
+    print "🎉 Simple predicate function tests completed!"
+    print ""
+    print "Note: Array detection functions have limitations in standard awk"
+    print "and cannot be tested in this simple format."
+} 
\ No newline at end of file