From c30588cf80caa6011451f43e9a752a6d03fb14c3 Mon Sep 17 00:00:00 2001 From: Alberto Lerda Date: Wed, 8 Mar 2023 15:17:33 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`and`=20in=20forea?= =?UTF-8?q?ch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/meson.build | 2 +- src/lua/zencode.lua | 5 +++++ test/zencode/and.bats | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 test/zencode/and.bats 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 <