From f32c1036c28d1b51b3c3534d9e632f0f6723abfc Mon Sep 17 00:00:00 2001 From: Productive2 <48047721+Productive2@users.noreply.github.com> Date: Fri, 26 Feb 2021 22:42:36 +0100 Subject: [PATCH] Allow // in test definitions. --- tests/japl/fib.jpl | 12 ++++++++---- tests/testbuilder.nim | 11 +++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/japl/fib.jpl b/tests/japl/fib.jpl index b42cdf2..bbd8fca 100644 --- a/tests/japl/fib.jpl +++ b/tests/japl/fib.jpl @@ -1,5 +1,7 @@ -[Test: fibonacci] -[source: raw] + +//[Test: fibonacci] + +//[source: raw] fun fib(n) { if (n < 2) return n; @@ -14,7 +16,8 @@ print(fib(6)); print(fib(7)); print(fib(8)); print(fib(9)); -[end] +//[end] +/* [stdout] 1 1 @@ -26,4 +29,5 @@ print(fib(9)); 21 34 [end] -[end] +*/ +//[end] diff --git a/tests/testbuilder.nim b/tests/testbuilder.nim index 42289bf..88e9d61 100644 --- a/tests/testbuilder.nim +++ b/tests/testbuilder.nim @@ -30,8 +30,8 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri ## if comment is true, the returned value has to be ignored # when non modal, mode becomes the line # when comment is true, it must not do anything to whenever it is exported - let line = line # initialize result + var start = 0 result.modal = false result.mode = "" result.detail = "" @@ -48,14 +48,21 @@ proc parseModalLine(line: string): tuple[modal: bool, mode: string, detail: stri result.modal = true return result result.modal = true + start = 1 # not modal line early return + elif line.len() >= 3 and line[0..2] == "//[": + if line.len() > 3: + result.modal = true + start = 3 + else: + fatal "Invalid line //[, no mode defined." else: result.mode = line return result # normal modal line: var colon = false # if there has been a colon already - for i in countup(0, line.high()): + for i in countup(start, line.high()): let ch = line[i] if ch in Letters or ch in Digits or ch in {'_', '-'}: # legal characters