diff options
author | Eduardo Julian | 2022-03-30 14:46:09 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-03-30 14:46:09 -0400 |
commit | 8ebc505f1be8e103039d220b2d824dd687777f24 (patch) | |
tree | c439d60e014540de5bbfaa773664aec8acc85ee7 | |
parent | 381ec5920d9ebeb335963778dec182268819e718 (diff) |
"when" macro for Try.
-rw-r--r-- | .github/workflows/setup_aedifex.yml | 9 | ||||
-rw-r--r-- | .github/workflows/test.yml | 11 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/try.lux | 16 |
3 files changed, 26 insertions, 10 deletions
diff --git a/.github/workflows/setup_aedifex.yml b/.github/workflows/setup_aedifex.yml new file mode 100644 index 000000000..5afa83812 --- /dev/null +++ b/.github/workflows/setup_aedifex.yml @@ -0,0 +1,9 @@ +name: 'Setup Aedifex' +runs: + using: "composite" + steps: + - uses: actions/checkout@v2 + - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_3.jar && mv aedifex_do_not_touch_3.jar aedifex.jar + - run: mv ./shell/lux.sh ./lux.sh + - run: cd ./stdlib/ && ../lux.sh clean && cd .. + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f3d30cd3..dfdeff165 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,17 +1,10 @@ name: test_everything on: [push] jobs: - setup_aedifex: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_3.jar && mv aedifex_do_not_touch_3.jar aedifex.jar - - run: mv ./shell/lux.sh ./lux.sh - - run: cd ./stdlib/ && ../lux.sh clean && cd .. test_stdlib_on_jvm: - needs: [setup_aedifex] runs-on: ubuntu-latest steps: + - uses: ./.github/workflows/setup_aedifex # https://github.com/actions/setup-java - uses: actions/setup-java@v2 with: @@ -20,9 +13,9 @@ jobs: - uses: actions/checkout@v2 - run: cd ./stdlib/ && ../lux.sh with jvm with bibliotheca test test_stdlib_on_node_js: - needs: [setup_aedifex] runs-on: ubuntu-latest steps: + - uses: ./.github/workflows/setup_aedifex # https://github.com/actions/setup-node - uses: actions/setup-node@v2 with: diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 4da14bb92..d00d15d28 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -150,4 +150,18 @@ (~ else))))]} _ - {#Failure "Wrong syntax for else"})) + {#Failure "Wrong syntax for 'else'"})) + +(macro: .public (when tokens state) + (case tokens + (pattern (.list test then)) + (let [code#encoded ("lux in-module" "library/lux" .code#encoded) + text$ ("lux in-module" "library/lux" .text$)] + {.#Right [state (.list (` (.if (~ test) + (~ then) + {..#Failure (~ (text$ ($_ "lux text concat" + "[" (code#encoded (` .when)) "]" + " " "Invalid condition:")))})))]}) + + _ + {.#Left "Wrong syntax for 'when'"})) |