diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/config.nims | 2 | ||||
-rw-r--r-- | tests/controlflow/tcontrolflow.nim | 21 | ||||
-rw-r--r-- | tests/controlflow/tunamedbreak.nim | 15 | ||||
-rw-r--r-- | tests/exception/texceptionbreak.nim | 8 | ||||
-rw-r--r-- | tests/iter/titer_issues.nim | 4 |
5 files changed, 43 insertions, 7 deletions
diff --git a/tests/config.nims b/tests/config.nims index b08a697a8..421cabbf3 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -42,3 +42,5 @@ switch("define", "nimPreviewHashRef") switch("define", "nimPreviewRangeDefault") when defined(windows): switch("tlsEmulation", "off") + +switch("warningAserror", "UnnamedBreak") diff --git a/tests/controlflow/tcontrolflow.nim b/tests/controlflow/tcontrolflow.nim index 258f3f50d..dd21a2bb6 100644 --- a/tests/controlflow/tcontrolflow.nim +++ b/tests/controlflow/tcontrolflow.nim @@ -19,7 +19,7 @@ block tbreak: run = false block myblock: if true: - break + break myblock echo "leaving myblock" x = true doAssert(x) @@ -95,3 +95,22 @@ block tnestif: else: writeLine(stdout, "looks like Python") #OUT i == 2 + +# bug https://github.com/nim-lang/RFCs/issues/451 +for i in 1..2: # works + break + +block: # works + for i in 1..2: + break + +block: # works + block: + discard 12 + 3 + for i in 1..2: + break + +block named: # works + if true: + break named + doAssert false, "not reached" diff --git a/tests/controlflow/tunamedbreak.nim b/tests/controlflow/tunamedbreak.nim new file mode 100644 index 000000000..46113cabc --- /dev/null +++ b/tests/controlflow/tunamedbreak.nim @@ -0,0 +1,15 @@ + +discard """ + cmd: "nim check $file" + action: "reject" + nimout: ''' +tunamedbreak.nim(12, 5) Error: Using an unnamed break in a block is deprecated; Use a named block with a named break instead [UnnamedBreak] +tunamedbreak.nim(15, 3) Error: Using an unnamed break in a block is deprecated; Use a named block with a named break instead [UnnamedBreak] + ''' +""" +for i in 1..2: # errors + block: + break + +block: # errors + break diff --git a/tests/exception/texceptionbreak.nim b/tests/exception/texceptionbreak.nim index 6548192c6..b8ce7eead 100644 --- a/tests/exception/texceptionbreak.nim +++ b/tests/exception/texceptionbreak.nim @@ -29,16 +29,16 @@ echo "2" try: raise newException(OSError, "Problem") except OSError: - block: - break + block label: + break label echo "3" # Fourth Variety -block: +block label: try: raise newException(OSError, "Problem") except OSError: - break + break label echo "4" diff --git a/tests/iter/titer_issues.nim b/tests/iter/titer_issues.nim index 7dee9792d..adba8a8e3 100644 --- a/tests/iter/titer_issues.nim +++ b/tests/iter/titer_issues.nim @@ -369,9 +369,9 @@ block: # bug #18824 iterator poc_iterator: int {.closure.} = - block: + block bug18824: try: - break + break bug18824 finally: echo "In defer" |