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_history411
1 files changed, 211 insertions, 200 deletions
diff --git a/js/scripting-lang/repl/.repl_history b/js/scripting-lang/repl/.repl_history
index 32607e5..6f69f53 100644
--- a/js/scripting-lang/repl/.repl_history
+++ b/js/scripting-lang/repl/.repl_history
@@ -1,205 +1,216 @@
-/* Create and process state */
-x : 5;
-y : 10;
-sum : x + y;
-result : { x, y, sum };
-/* Return processed state */
-result
-double : x -> 
-    x * 2;
-result : double 10;
-age : 25;
-status : when age is 
-    age >= 18 then "adult" 
-    _ then "minor";
-result : { age, status };
-numbers : {1: 1, 2: 2, 3: 3, 4: 4, 5: 5};
-double : x -> x * 2;
-filter_even : x -> when x % 2 is 0 then true _ then false;
-doubled : map @double numbers;
-even_numbers : filter @filter_even doubled;
-result : { 
-    original: numbers, 
-    doubled: doubled, 
-    even: even_numbers 
+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"
+    }
 };
-x : 3;
-y : 3;
-y + y;
-add y y;
-apply add y x;
-/* Basic state management example */
-/* Create and process state */
-x : 5;
-y : 10;
-sum : x + y;
-result : { x, y, sum };
-/* Return processed state */
-result
-/* Basic state management example */
-/* Create and process state */
-x : 5;
-y : 10;
-sum : x + y;
-result : { x, y, sum };
-/* Return processed state */
-result
-test : a b c -> (a + b) / c;
-test 12 12 100
-sum : x + y;
-x : 42;
-result : when x is
-42 then "the result"
-_  then "nope"
-acc : x y -> x + y;
-acc 3 3;
-add_func : x y -> x + y;
-add_func 3 3;
-add_func : x y -> x + y;
-result : add_func 3 3;
-acc : x y -> x + y;
-result : acc 3 3;
-x : 5; y : 10; sum : x + y;
-double : x -> x * 2; result : double sum;
-square : x -> x * x; squared : square result;
-/* Recursive functions example */
-/* Factorial function */
-factorial : n -> 
-    when n is
-        0 then 1
-        _ then n * (factorial (n - 1));
-/* Fibonacci function */
-fibonacci : n ->
-    when n is
-        0 then 0
-        1 then 1
-        _ then (fibonacci (n - 1)) + (fibonacci (n - 2));
-/* Test factorial */
-fact_5 : factorial 5;
-fact_0 : factorial 0;
-/* Test fibonacci */
-fib_6 : fibonacci 6;
-fib_10 : fibonacci 10;
-/* Return results */
-{ factorial, fibonacci, fact_5, fact_0, fib_6, fib_10 }10 }
-/* FizzBuzz recursive example */
-/* FizzBuzz function using recursion with tables */
-fizzbuzz : n ->
-    when n is
-        0 then {}
-        _ then 
-            { (fizzbuzz (n - 1)), n: 
-                when n is
-                    n % 15 == 0 then "FizzBuzz"
-                    n % 3 == 0 then "Fizz"
-                    n % 5 == 0 then "Buzz"
-                    _ then n
-            };
-/* Test FizzBuzz for first 15 numbers */
-result : fizzbuzz 15;
-/* Also test smaller ranges */
-fizzbuzz_5 : fizzbuzz 5;
-fizzbuzz_10 : fizzbuzz 10;
-/* Return results */
-{ fizzbuzz, result, fizzbuzz_5, fizzbuzz_10 }
-fizzbuzz_20 : fizzbuzz 20; fizzbuzz_30 : fizzbuzz 30;
-fizzbuzz_0 : fizzbuzz 0; fizzbuzz_1 : fizzbuzz 1;
-/* FizzBuzz recursive example */
-/* FizzBuzz function using recursion with tables */
-fizzbuzz : n ->
-    when n is
-        0 then {}
-        _ then 
-            { (fizzbuzz (n - 1)), n: 
-                when n is
-                    n % 15 = 0 then "FizzBuzz"
-                    n % 3 = 0 then "Fizz"
-                    n % 5 = 0 then "Buzz"
-                    _ then n
-            };
-/* Test FizzBuzz for first 15 numbers */
-result : fizzbuzz 15;
-/* Also test smaller ranges */
-fizzbuzz_5 : fizzbuzz 5;
-fizzbuzz_10 : fizzbuzz 10;
-/* Return results */
-{ fizzbuzz, result, fizzbuzz_5, fizzbuzz_10 }
-fizzbuzz_20 : fizzbuzz 20; fizzbuzz_30 : fizzbuzz 30;
-fizzbuzz_0 : fizzbuzz 0; fizzbuzz_1 : fizzbuzz 1;
-/* FizzBuzz recursive example */
-/* FizzBuzz function using recursion with tables */
-fizzbuzz : n ->
-    when n is
-        0 then {}
-        _ then 
-            { (fizzbuzz (n - 1)), n: 
-                when n is
-                    n % 15 = 0 then "FizzBuzz"
-                    n % 3 = 0 then "Fizz"
-                    n % 5 = 0 then "Buzz"
-                    _ then n
-            };
-/* Test FizzBuzz for first 15 numbers */
-result : fizzbuzz 15;
-/* Also test smaller ranges */
-fizzbuzz_5 : fizzbuzz 5;
-fizzbuzz_10 : fizzbuzz 10;
-/* Return results */
-{ fizzbuzz, result, fizzbuzz_5, fizzbuzz_10 }
-result : fizzbuzz 5;
-/* FizzBuzz recursive example */
-/* FizzBuzz function using recursion with tables */
-fizzbuzz : n ->
-    when n is
-        0 then {}
-        _ then 
-            { (fizzbuzz (n - 1)), n: 
-                when n is
-                    n % 15 = 0 then "FizzBuzz"
-                    n % 3 = 0 then "Fizz"
-                    n % 5 = 0 then "Buzz"
-                    _ then n
-            };
-/* Test FizzBuzz for first 15 numbers */
-result : fizzbuzz 15;
-/* Also test smaller ranges */
-fizzbuzz_5 : fizzbuzz 5;
-fizzbuzz_10 : fizzbuzz 10;
-/* Return results */
-{ fizzbuzz, result, fizzbuzz_5, fizzbuzz_10 }
-/* Network API integration example */
-/* Using PokéAPI to fetch Pokémon data */
-/* Get current state to see if we have a Pokémon name */
+/* 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;
-/* Determine which Pokémon to fetch */
-pokemon_name : when state is
-    { pokemon: name } then name
-    _ then "ditto";  /* Default to ditto */
-/* Emit network request to PokéAPI */
-..emit { 
-    action: "http_request", 
-    method: "GET", 
-    url: "https://pokeapi.co/api/v2/pokemon/" + pokemon_name 
+/* 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
 };
-/* Also fetch a list of Pokémon */
-..emit { 
-    action: "http_request", 
-    method: "GET", 
-    url: "https://pokeapi.co/api/v2/pokemon?limit=5" 
+/* 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 the request configuration */
-{ 
-    pokemon_name, 
-    requests: [
-        { method: "GET", url: "https://pokeapi.co/api/v2/pokemon/" + pokemon_name },
-        { method: "GET", url: "https://pokeapi.co/api/v2/pokemon?limit=5" }
-    ]
+/* Return request info */
+{
+    request_type: "GET",
+    url: "https://jsonplaceholder.typicode.com/posts/1",
+    description: "Fetching a sample post from JSONPlaceholder"
 }
-..emit { action: "http_request", method: "GET", url: "https://pokeapi.co/api/v2/pokemon/ditto" };
-..emit { action: "http_request", method: "GET", url: "https://pokeapi.co/api/v2/pokemon/ditto" };
-test : 42;
-..emit { action: "http_request", method: "GET", url: "https://pokeapi.co/api/v2/pokemon/ditto" };
-..emit { action: "http_request", method: "GET", url: "https://pokeapi.co/api/v2/pokemon/ditto" };
-test : 42;
-test : 42;kemon/ditto" };
-test : 42;
\ No newline at end of file
+..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