From e4a719344f2d3bf6008d15949baf60fa68420135 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 14 Jul 2022 17:39:58 +0800 Subject: add spec. --- spec/inputs/switch.yue | 10 ++++++++++ spec/outputs/switch.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/spec/inputs/switch.yue b/spec/inputs/switch.yue index 08330bf..442d15f 100644 --- a/spec/inputs/switch.yue +++ b/spec/inputs/switch.yue @@ -108,10 +108,20 @@ do do tb = {} + switch tb when {:a = 1, :b = 2} print a, b + switch tb + when {:a, :b = 2} + print "partially matched", a, b + + switch tb + when {:a, :b} + print a, b + else + print "not matched" do tb = x: "abc" switch tb diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index c4cde26..4358027 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua @@ -247,6 +247,34 @@ do print(a, b) end end + do + local _tab_0 = "table" == type(tb) + if _tab_0 then + local a = tb.a + local b = tb.b + if b == nil then + b = 2 + end + if a ~= nil then + print("partially matched", a, b) + end + end + end + do + local _tab_0 = "table" == type(tb) + local _match_0 = false + if _tab_0 then + local a = tb.a + local b = tb.b + if a ~= nil and b ~= nil then + _match_0 = true + print(a, b) + end + end + if not _match_0 then + print("not matched") + end + end end do local tb = { -- cgit v1.2.3-55-g6feb