diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-03-18 11:23:55 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-18 12:03:57 +0000 |
| commit | f480c0b670725c10d6f431d67b1c0ca54e679916 (patch) | |
| tree | 38e2c116b18e453f1a7b175f05ed38828d65f7be /spec | |
| parent | lib: add glsl-view (diff) | |
| download | alive-f480c0b670725c10d6f431d67b1c0ca54e679916.tar.gz alive-f480c0b670725c10d6f431d67b1c0ca54e679916.zip | |
builtins: switch takes single array as value
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/builtins/cond_spec.moon | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/lib/builtins/cond_spec.moon b/spec/lib/builtins/cond_spec.moon index 89f7c7e..04c56ef 100644 --- a/spec/lib/builtins/cond_spec.moon +++ b/spec/lib/builtins/cond_spec.moon @@ -90,3 +90,18 @@ describe "when", -> assert.is.true \is_const! assert.is.equal '<num[3]= [1 2 3]>', tostring .result + +describe "switch", -> + COPILOT = TestPilot! + + it "switches by num", -> + for key, val in pairs {[0]: 11, [0.5]: 11, 22, 33, 11} + with COPILOT\eval_once "(switch #{key} 11 22 33)" + assert.is.true \is_const! + assert.is.equal val, .result! + + it "switches arrays by num", -> + for key, val in pairs {[0]: 11, [0.5]: 11, 22, 33, 11} + with COPILOT\eval_once "(switch #{key} [11 22 33])" + assert.is.true \is_const! + assert.is.equal val, .result! |
