From 267ed9a1a6848e7bf7ef7707b7d71c8ee4181e29 Mon Sep 17 00:00:00 2001 From: s-ol Date: Thu, 21 May 2020 17:00:38 +0200 Subject: base.match: fix bug when repeating multi-element patterns --- spec/match_spec.moon | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'spec') diff --git a/spec/match_spec.moon b/spec/match_spec.moon index 9764d5d..0047fd4 100644 --- a/spec/match_spec.moon +++ b/spec/match_spec.moon @@ -263,6 +263,15 @@ describe 'repeat', -> assert.has.error -> rep\match (times 3, str) assert.has.error -> rep\match (times 2, num) + it 'works with complex inner types', -> + rep = (val.num + val.str)\rep 2, 2 + assert.has.error -> rep\match {} + assert.has.error -> rep\match {num, str} + assert.has.error -> rep\match {num, num} + assert.is.same {{num, str}, {num, str}}, rep\match {num, str, num, str} + assert.has.error -> rep\match {str, str, str, str} + assert.has.error -> rep\match {num, str, num, str, num, str} + it 'stringifies well', -> assert.is.equal 'str~{1-3}', tostring val.str*3 assert.is.equal 'str~{1-*}', tostring val.str*0 -- cgit v1.2.3