diff --git a/build/meson.build b/build/meson.build index 16251d9fb..e6551f0a7 100644 --- a/build/meson.build +++ b/build/meson.build @@ -187,7 +187,7 @@ test_dir = meson.source_root() + '/../test/' bats_bin = find_program(test_dir+'bats/bin/bats') tests = [ 'array', 'dictionary', 'branching', 'float', 'generic_ecdh', 'generic_eddsa', 'generic_schnorr', 'generic_dilithium', - 'zkp', 'credential', 'bitcoin', 'ecdh', 'foreach' ] + 'zkp', 'credential', 'bitcoin', 'ecdh', 'foreach', 'and' ] foreach test_suite : tests test('zencode_'+test_suite.underscorify(), bats_bin, diff --git a/src/lua/zencode.lua b/src/lua/zencode.lua index f4fbc9e08..0c78ba5f3 100644 --- a/src/lua/zencode.lua +++ b/src/lua/zencode.lua @@ -295,6 +295,11 @@ local function new_state_machine() {name = 'enter_and', from = 'whenif', to = 'whenif'}, {name = 'enter_and', from = 'thenif', to = 'thenif'}, {name = 'enter_and', from = 'if', to = 'if'}, + {name = 'enter_and', from = 'foreach', to = 'foreach'}, + {name = 'enter_and', from = 'ifforeach', to = 'ifforeach'}, + {name = 'enter_and', from = 'foreachif', to = 'foreachif'}, + {name = 'enter_and', from = 'whenforeach', to = 'whenforeach'}, + {name = 'enter_and', from = 'whenifforeach', to = 'whenifforeach'}, }, -- graph TD diff --git a/test/zencode/and.bats b/test/zencode/and.bats new file mode 100755 index 000000000..4e6490ea7 --- /dev/null +++ b/test/zencode/and.bats @@ -0,0 +1,33 @@ +load ../bats_setup +load ../bats_zencode +SUBDOC=and + +@test "And inside foreach" { + cat <