about summary refs log tree commit diff stats
path: root/js/scripting-lang/repl/.repl_history
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/repl/.repl_history')
-rw-r--r--js/scripting-lang/repl/.repl_history547
1 files changed, 216 insertions, 331 deletions
diff --git a/js/scripting-lang/repl/.repl_history b/js/scripting-lang/repl/.repl_history
index 679f4a5..6f69f53 100644
--- a/js/scripting-lang/repl/.repl_history
+++ b/js/scripting-lang/repl/.repl_history
@@ -1,331 +1,216 @@
-{1: true, 2: false} then "Fizz"
-{1: false, 2: true} then "Buzz"
-{1: false, 2: false} then n
-/* Test FizzBuzz with various inputs */
-..out "FizzBuzz results:"
-..out "fizzbuzz 15: " + fizzbuzz 15;
-..out "fizzbuzz 3: " + fizzbuzz 3;
-..out "fizzbuzz 5: " + fizzbuzz 5;
-..out "fizzbuzz 7: " + fizzbuzz 7;
-..out "fizzbuzz 0: " + fizzbuzz 0;
-..out "fizzbuzz 1: " + fizzbuzz 1;
-/* ===== TEST 5: ALTERNATIVE APPROACHES ===== */
-..out "=== TEST 5: ALTERNATIVE APPROACHES ==="
-/* Option A: Multiple value patterns */
-fizzbuzz_option_a : n ->
-when (equals (n % 3) 0) (equals (n % 5) 0) is
-true true then "FizzBuzz"
-true false then "Fizz"
-false true then "Buzz"
-false false then n
-..out "Option A (multiple value patterns):";
-..out "fizzbuzz_option_a 15: " + fizzbuzz_option_a 15;
-..out "fizzbuzz_option_a 3: " + fizzbuzz_option_a 3;
-..out "fizzbuzz_option_a 5: " + fizzbuzz_option_a 5;
-..out "fizzbuzz_option_a 7: " + fizzbuzz_option_a 7;
-/* Option B: Predicate functions with nested when */
-is_fizzbuzz : n -> apply @logicalAnd (equals (n % 3) 0) (equals (n % 5) 0)
-is_fizz : n -> equals (n % 3) 0;
-is_buzz : n -> equals (n % 5) 0;
-fizzbuzz_option_b : n ->
-when is_fizzbuzz n is
-true then "FizzBuzz"
-_ then when is_fizz n is
-true then "Fizz"
-_ then when is_buzz n is
-true then "Buzz"
-_ then n
-..out "Option B (predicate functions):";
-..out "fizzbuzz_option_b 15: " + fizzbuzz_option_b 15;
-..out "fizzbuzz_option_b 3: " + fizzbuzz_option_b 3;
-..out "fizzbuzz_option_b 5: " + fizzbuzz_option_b 5;
-..out "fizzbuzz_option_b 7: " + fizzbuzz_option_b 7;
-/* ===== TEST 6: EDGE CASES AND ERROR CONDITIONS ===== */
-..out "=== TEST 6: EDGE CASES AND ERROR CONDITIONS ==="
-/* Test with negative numbers */
-..out "Negative numbers:"
-..out "fizzbuzz -3: " + fizzbuzz -3;
-..out "fizzbuzz -5: " + fizzbuzz -5;
-..out "fizzbuzz -15: " + fizzbuzz -15;
-/* Test with large numbers */
-..out "Large numbers:"
-..out "fizzbuzz 30: " + fizzbuzz 30;
-..out "fizzbuzz 45: " + fizzbuzz 45;
-..out "fizzbuzz 60: " + fizzbuzz 60;
-/* ===== TEST 7: PERFORMANCE AND COMPLEXITY ===== */
-..out "=== TEST 7: PERFORMANCE AND COMPLEXITY ==="
-/* Test with a range of numbers */
-test_range : 1
-test_result : fizzbuzz test_range;
-..out "Range test (1-20):";
-..out "1: " + test_result;
-test_range : 2;
-test_result : fizzbuzz test_range;
-..out "2: " + test_result;
-test_range : 3;
-test_result : fizzbuzz test_range;
-..out "3: " + test_result;
-test_range : 4;
-test_result : fizzbuzz test_range;
-..out "4: " + test_result;
-test_range : 5;
-test_result : fizzbuzz test_range;
-..out "5: " + test_result;
-test_range : 6;
-test_result : fizzbuzz test_range;
-..out "6: " + test_result;
-test_range : 7;
-test_result : fizzbuzz test_range;
-..out "7: " + test_result;
-test_range : 8;
-test_result : fizzbuzz test_range;
-..out "8: " + test_result;
-test_range : 9;
-test_result : fizzbuzz test_range;
-..out "9: " + test_result;
-test_range : 10;
-test_result : fizzbuzz test_range;
-..out "10: " + test_result;
-test_range : 11;
-test_result : fizzbuzz test_range;
-..out "11: " + test_result;
-test_range : 12;
-test_result : fizzbuzz test_range;
-..out "12: " + test_result;
-test_range : 13;
-test_result : fizzbuzz test_range;
-..out "13: " + test_result;
-test_range : 14;
-test_result : fizzbuzz test_range;
-..out "14: " + test_result;
-test_range : 15;
-test_result : fizzbuzz test_range;
-..out "15: " + test_result;
-..out "=== VERIFICATION COMPLETE ===";
-/* Enhanced Case Statement Verification Tests */
-/* Testing core assumptions for FizzBuzz and tuple-like pattern matching */
-/* ===== TEST 1: AUTO-INDEXED TABLE CREATION ===== */
-..out "=== TEST 1: AUTO-INDEXED TABLE CREATION ==="
-/* Test basic auto-indexed table */
-basic_table : {1, 2, 3}
-..out "Basic table:";
-..out basic_table;
-/* Test auto-indexed table with expressions */
-expr_table : {5 % 3, 5 % 5, 5 % 2}
-..out "Expression table (5 % 3, 5 % 5, 5 % 2):";
-..out expr_table;
-/* Test with FizzBuzz-style expressions */
-n : 15
-fizzbuzz_expr : {n % 3, n % 5};
-..out "FizzBuzz expressions for n=15:";
-..out fizzbuzz_expr;
-/* ===== TEST 2: MAP WITH TABLE TRANSFORMATION ===== */
-..out "=== TEST 2: MAP WITH TABLE TRANSFORMATION ==="
-/* Test map with equals 0 */
-test_map : map @(equals 0) {15 % 3, 15 % 5}
-..out "Map equals 0 on {15 % 3, 15 % 5}:";
-..out test_map;
-/* Test with different numbers */
-test_map_3 : map @(equals 0) {3 % 3, 3 % 5}
-..out "Map equals 0 on {3 % 3, 3 % 5}:";
-..out test_map_3;
-test_map_5 : map @(equals 0) {5 % 3, 5 % 5};
-..out "Map equals 0 on {5 % 3, 5 % 5}:";
-..out test_map_5;
-test_map_7 : map @(equals 0) {7 % 3, 7 % 5};
-..out "Map equals 0 on {7 % 3, 7 % 5}:";
-..out test_map_7;
-/* ===== TEST 3: TABLE PATTERN MATCHING ===== */
-..out "=== TEST 3: TABLE PATTERN MATCHING ==="
-/* Test simple table pattern matching */
-simple_table : {1: true, 2: false}
-simple_result : when simple_table is
-{1: true, 2: true} then "both true"
-{1: true, 2: false} then "first true"
-{1: false, 2: true} then "second true"
-{1: false, 2: false} then "both false"
-..out "Simple table pattern matching:";
-..out simple_result;
-/* Test with actual FizzBuzz-style data */
-fizzbuzz_data : {1: true, 2: true}
-fizzbuzz_result : when fizzbuzz_data is
-{1: true, 2: true} then "FizzBuzz"
-{1: true, 2: false} then "Fizz"
-{1: false, 2: true} then "Buzz"
-{1: false, 2: false} then "neither"
-..out "FizzBuzz-style pattern matching:";
-..out fizzbuzz_result;
-/* Test with different combinations */
-fizz_data : {1: true, 2: false}
-fizz_result : when fizz_data is
-{1: true, 2: true} then "FizzBuzz"
-{1: true, 2: false} then "Fizz"
-{1: false, 2: true} then "Buzz"
-{1: false, 2: false} then "neither"
-..out "Fizz pattern matching:";
-..out fizz_result;
-/* ===== TEST 4: INTEGRATED FIZZBUZZ TEST ===== */
-..out "=== TEST 4: INTEGRATED FIZZBUZZ TEST ==="
-/* Create the divisibility function */
-divisibility : n -> map @(equals 0) {n % 3, n % 5}
-/* Test the function with different inputs */
-div_15 : divisibility 15
-div_3 : divisibility 3;
-div_5 : divisibility 5;
-div_7 : divisibility 7;
-..out "Divisibility results:";
-..out "15: " + div_15;
-..out "3: " + div_3;
-..out "5: " + div_5;
-..out "7: " + div_7;
-/* Test the complete FizzBuzz function */
-fizzbuzz : n ->
-when divisibility n is
-{1: true, 2: true} then "FizzBuzz"
-{1: true, 2: false} then "Fizz"
-{1: false, 2: true} then "Buzz"
-{1: false, 2: false} then n
-/* Test FizzBuzz with various inputs */
-..out "FizzBuzz results:"
-..out "fizzbuzz 15: " + fizzbuzz 15;
-..out "fizzbuzz 3: " + fizzbuzz 3;
-..out "fizzbuzz 5: " + fizzbuzz 5;
-..out "fizzbuzz 7: " + fizzbuzz 7;
-..out "fizzbuzz 0: " + fizzbuzz 0;
-..out "fizzbuzz 1: " + fizzbuzz 1;
-/* ===== TEST 5: ALTERNATIVE APPROACHES ===== */
-..out "=== TEST 5: ALTERNATIVE APPROACHES ==="
-/* Option A: Multiple value patterns */
-fizzbuzz_option_a : n ->
-when (equals (n % 3) 0) (equals (n % 5) 0) is
-true true then "FizzBuzz"
-true false then "Fizz"
-false true then "Buzz"
-false false then n
-..out "Option A (multiple value patterns):";
-..out "fizzbuzz_option_a 15: " + fizzbuzz_option_a 15;
-..out "fizzbuzz_option_a 3: " + fizzbuzz_option_a 3;
-..out "fizzbuzz_option_a 5: " + fizzbuzz_option_a 5;
-..out "fizzbuzz_option_a 7: " + fizzbuzz_option_a 7;
-/* Option B: Predicate functions with nested when */
-is_fizzbuzz : n -> apply @logicalAnd (equals (n % 3) 0) (equals (n % 5) 0)
-is_fizz : n -> equals (n % 3) 0;
-is_buzz : n -> equals (n % 5) 0;
-fizzbuzz_option_b : n ->
-when is_fizzbuzz n is
-true then "FizzBuzz"
-_ then when is_fizz n is
-true then "Fizz"
-_ then when is_buzz n is
-true then "Buzz"
-_ then n
-..out "Option B (predicate functions):";
-..out "fizzbuzz_option_b 15: " + fizzbuzz_option_b 15;
-..out "fizzbuzz_option_b 3: " + fizzbuzz_option_b 3;
-..out "fizzbuzz_option_b 5: " + fizzbuzz_option_b 5;
-..out "fizzbuzz_option_b 7: " + fizzbuzz_option_b 7;
-/* ===== TEST 6: EDGE CASES AND ERROR CONDITIONS ===== */
-..out "=== TEST 6: EDGE CASES AND ERROR CONDITIONS ==="
-/* Test with negative numbers */
-..out "Negative numbers:"
-..out "fizzbuzz -3: " + fizzbuzz -3;
-..out "fizzbuzz -5: " + fizzbuzz -5;
-..out "fizzbuzz -15: " + fizzbuzz -15;
-/* Test with large numbers */
-..out "Large numbers:"
-..out "fizzbuzz 30: " + fizzbuzz 30;
-..out "fizzbuzz 45: " + fizzbuzz 45;
-..out "fizzbuzz 60: " + fizzbuzz 60;
-/* ===== TEST 7: PERFORMANCE AND COMPLEXITY ===== */
-..out "=== TEST 7: PERFORMANCE AND COMPLEXITY ==="
-/* Test with a range of numbers */
-test_range : 1
-test_result : fizzbuzz test_range;
-..out "Range test (1-20):";
-..out "1: " + test_result;
-test_range : 2;
-test_result : fizzbuzz test_range;
-..out "2: " + test_result;
-test_range : 3;
-test_result : fizzbuzz test_range;
-..out "3: " + test_result;
-test_range : 4;
-test_result : fizzbuzz test_range;
-..out "4: " + test_result;
-test_range : 5;
-test_result : fizzbuzz test_range;
-..out "5: " + test_result;
-test_range : 6;
-test_result : fizzbuzz test_range;
-..out "6: " + test_result;
-test_range : 7;
-test_result : fizzbuzz test_range;
-..out "7: " + test_result;
-test_range : 8;
-test_result : fizzbuzz test_range;
-..out "8: " + test_result;
-test_range : 9;
-test_result : fizzbuzz test_range;
-..out "9: " + test_result;
-test_range : 10;
-test_result : fizzbuzz test_range;
-..out "10: " + test_result;
-test_range : 11;
-test_result : fizzbuzz test_range;
-..out "11: " + test_result;
-test_range : 12;
-test_result : fizzbuzz test_range;
-..out "12: " + test_result;
-test_range : 13;
-test_result : fizzbuzz test_range;
-..out "13: " + test_result;
-test_range : 14;
-test_result : fizzbuzz test_range;
-..out "14: " + test_result;
-test_range : 15;
-test_result : fizzbuzz test_range;
-..out "15: " + test_result;
-..out "=== VERIFICATION COMPLETE ===";
-/* Simple verification test for enhanced case statements */
-/* Test 1: Basic table creation */
-basic : {1, 2, 3}
-..out "Basic table:";
-..out basic;
-/* Test 2: Auto-indexed table with expressions */
-expr : {5 % 3, 5 % 5}
-..out "Expression table:";
-..out expr;
-/* Test 3: Map with equals 0 */
-mapped : map @(equals 0) {15 % 3, 15 % 5}
-..out "Mapped table:";
-..out mapped;
-/* Test 4: Simple table pattern matching */
-test_table : {1: true, 2: false}
-result : when test_table is
-{1: true, 2: true} then "both true"
-{1: true, 2: false} then "first true"
-{1: false, 2: true} then "second true"
-{1: false, 2: false} then "both false"
-..out "Pattern match result:";
-..out result;
-/* Test 5: FizzBuzz divisibility function */
-divisibility : n -> map @(equals 0) {n % 3, n % 5}
-div_15 : divisibility 15;
-..out "Divisibility for 15:";
-..out div_15;
-/* Test 6: Complete FizzBuzz */
-fizzbuzz : n ->
-when divisibility n is
-{1: true, 2: true} then "FizzBuzz"
-{1: true, 2: false} then "Fizz"
-{1: false, 2: true} then "Buzz"
-{1: false, 2: false} then n
-fizz_15 : fizzbuzz 15;
-fizz_3 : fizzbuzz 3;
-fizz_5 : fizzbuzz 5;
-fizz_7 : fizzbuzz 7;
-..out "FizzBuzz results:";
-..out "15: " + fizz_15;
-..out "3: " + fizz_3;
-..out "5: " + fizz_5;
-..out "7: " + fizz_7;
\ No newline at end of file
+first_mixed : mixed[1];
+name_mixed : mixed.name;
+second_mixed : mixed[2];
+..assert first_mixed = 1;
+..assert name_mixed = "Bob";
+..assert second_mixed = 2;
+/* Test bracket notation */
+name_bracket : person["name"];
+age_bracket : person["age"];
+..assert name_bracket = "Alice";
+..assert age_bracket = 30;
+..out "Tables test completed"; 
+/* HTTP GET request example */
+/* Simple GET request to JSONPlaceholder API */
+/* Make a GET request to fetch a post */
+..emit {
+    action: "http_request",
+    method: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    headers: {
+        "Accept": "application/json"
+    }
+};
+/* Return request info */
+{
+    request_type: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    description: "Fetching a sample post from JSONPlaceholder"
+}
+/* HTTP GET request example */
+/* Simple GET request to JSONPlaceholder API */
+/* Make a GET request to fetch a post */
+..emit {
+    action: "http_request",
+    method: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    headers: {
+        "Accept": "application/json"
+    }
+};
+/* Return request info */
+{
+    request_type: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    description: "Fetching a sample post from JSONPlaceholder"
+}
+/* File operations example */
+/* Demonstrates file adapter integration */
+/* Get current state */
+state : ..listen;
+/* Read a file using file adapter */
+..emit {
+    action: "read_file",
+    filename: "tests/09_tables.txt"
+};
+/* Save current state to file */
+..emit {
+    action: "save_file",
+    filename: "current_state.json",
+    data: state
+};
+/* Return operation info */
+{
+    operations: [
+        { action: "read_file", filename: "tests/09_tables.txt" },
+        { action: "save_file", filename: "current_state.json", data: state }
+    ],
+    note: "File operations processed through file adapter"
+}
+/* File adapter demonstration */
+/* This script uses the file adapter to read and execute the target file */
+/* Emit command to read the file using file adapter */
+..emit {
+    action: "read_file",
+    filename: "/Users/eli/Code/tour/js/scripting-lang/tests/09_tables.txt"
+};
+/* Return info about the operation */
+{
+    operation: "read_file",
+    filename: "/Users/eli/Code/tour/js/scripting-lang/tests/09_tables.txt",
+    note: "File content will be available through file adapter"
+}
+state : ..listen; result : { message: 'Hello from harness', state: state };
+state : ..listen; result : { message: "Hello from harness", state: state };
+/* HTTP GET request example */
+/* Simple GET request to JSONPlaceholder API */
+/* Make a GET request to fetch a post */
+..emit {
+    action: "http_request",
+    method: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    headers: {
+        "Accept": "application/json"
+    }
+};
+/* Return request info */
+{
+    request_type: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    description: "Fetching a sample post from JSONPlaceholder"
+}
+..emit { action: "test" };
+..emit { action: "http_request", method: "GET", url: "https://jsonplaceholder.typicode.com/posts/1" };
+..emit { action: "http_request", method: "GET", url: "https://jsonplaceholder.typicode.com/posts/1" };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+state : ..listen; result : { message: "Test state", version: 1 };
+/* Branching and state management demonstration */
+/* Shows advanced harness features */
+/* Get current state */
+state : ..listen;
+/* Create a branching scenario */
+branch_scenario : when state is
+    { action: "create_branch", name: branchName, fromVersion: version } then {
+        action: "branch_created",
+        branch_name: branchName,
+        base_version: version,
+        timestamp: Date.now(),
+        status: "ready"
+    }
+    { action: "merge_branch", source: sourceBranch, target: targetBranch } then {
+        action: "branch_merged",
+        source_branch: sourceBranch,
+        target_branch: targetBranch,
+        timestamp: Date.now(),
+        status: "merged"
+    }
+    { action: "compare_versions", from: fromVersion, to: toVersion } then {
+        action: "version_compared",
+        from_version: fromVersion,
+        to_version: toVersion,
+        timestamp: Date.now(),
+        status: "compared"
+    }
+    _ then {
+        action: "unknown",
+        timestamp: Date.now(),
+        status: "unknown"
+    };
+/* Log the branching operation */
+..emit {
+    action: "console_log",
+    message: "Branching operation: " + branch_scenario.action + " - " + branch_scenario.status
+};
+/* Save branch state */
+..emit {
+    action: "save_file",
+    filename: "branch_" + branch_scenario.action + "_" + Date.now() + ".json",
+    data: branch_scenario
+};
+/* Return branch scenario */
+branch_scenario
+state : ..listen; result : { message: "Initial state", version: 1 };
+state : ..listen; result : { message: "Updated state", version: 2, newField: "value" };
+state : ..listen; result : { message: "Test state", version: 1 };
+/* Error recovery and resilience demonstration */
+/* Shows how the harness handles errors gracefully */
+/* Get current state */
+state : ..listen;
+/* Simulate different error scenarios */
+error_scenario : when state is
+    { action: "simulate_timeout" } then {
+        action: "timeout_simulation",
+        retry_count: 0,
+        max_retries: 3,
+        status: "retrying"
+    }
+    { action: "simulate_network_error" } then {
+        action: "network_error_simulation",
+        retry_count: 0,
+        max_retries: 5,
+        backoff_delay: 2000,
+        status: "retrying"
+    }
+    { action: "simulate_script_error" } then {
+        action: "script_error_simulation",
+        recovery_action: "rollback",
+        rollback_version: state.version - 1,
+        status: "recovering"
+    }
+    { action: "test_resilience", data: testData } then {
+        action: "resilience_test",
+        test_data: testData,
+        attempts: 0,
+        max_attempts: 3,
+        status: "testing"
+    }
+    _ then {
+        action: "no_error",
+        status: "normal",
+        timestamp: Date.now()
+    };
+/* Log the error recovery operation */
+..emit {
+    action: "console_log",
+    message: "Error recovery: " + error_scenario.action + " - " + error_scenario.status
+};
+/* Save error recovery state */
+..emit {
+    action: "save_file",
+    filename: "error_recovery_" + error_scenario.action + ".json",
+    data: error_scenario
+};
+/* Return error scenario */
+error_scenario
+result : add 5 3;
+a : 1;
+b : 2;
+c : x y -> x + y;
+apply c a b;
+d : c a b;
\ No newline at end of file