summary refs log tree commit diff stats
path: root/nimpretty/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-07-18 12:13:22 +0200
committerAraq <rumpf_a@web.de>2019-07-18 12:13:22 +0200
commit6d8913ee1422143baebd438f7526208193c0bd5e (patch)
treeac97c5bd9b41e1fa8220be7914ae3709475578fe /nimpretty/tests
parent7deb49e992b734d5ae513460fdc9cf68d4000588 (diff)
downloadNim-6d8913ee1422143baebd438f7526208193c0bd5e.tar.gz
nimpretty: fixes #11616
Diffstat (limited to 'nimpretty/tests')
-rw-r--r--nimpretty/tests/exhaustive.nim36
-rw-r--r--nimpretty/tests/expected/exhaustive.nim36
2 files changed, 72 insertions, 0 deletions
diff --git a/nimpretty/tests/exhaustive.nim b/nimpretty/tests/exhaustive.nim
index 40ffd4f94..91ab530e4 100644
--- a/nimpretty/tests/exhaustive.nim
+++ b/nimpretty/tests/exhaustive.nim
@@ -786,3 +786,39 @@ if true:
     "foo1", "bar1", "foo2", "bar2", "foo3", "bar3", "foo4", "bar4", "foo5", "bar5", "foo6", "bar6", "foo7",
     "zzz", "ggg", "ddd",
   ]
+
+const b = true
+let fooB =
+  if true:
+    if b: 7 else: 8
+  else: ord(b)
+
+let foo = if cond:
+            if b: T else: F
+          else: b
+
+let a =
+  [[aaadsfas, bbb],
+   [ccc, ddd]]
+
+let b = [
+  [aaa, bbb],
+  [ccc, ddd]
+]
+
+# bug #11616
+proc newRecordGen(ctx: Context; typ: TypRef): PNode =
+  result = nkTypeDef.t(
+    newId(typ.optSym.name, true, pragmas = [id(if typ.isUnion: "cUnion"
+                                               else: "cStruct")]),
+    empty(),
+    nkObjectTy.t(
+      empty(),
+      empty(),
+      nkRecList.t(
+        typ.recFields.map(newRecFieldGen))))
+
+proc f =
+  # doesn't break the code, but leaving indentation as is would be nice.
+  let x = if true: callingProcWhatever()
+          else: callingADifferentProc()
diff --git a/nimpretty/tests/expected/exhaustive.nim b/nimpretty/tests/expected/exhaustive.nim
index 25521e970..247ece887 100644
--- a/nimpretty/tests/expected/exhaustive.nim
+++ b/nimpretty/tests/expected/exhaustive.nim
@@ -799,3 +799,39 @@ if true:
     "bar5", "foo6", "bar6", "foo7",
     "zzz", "ggg", "ddd",
   ]
+
+const b = true
+let fooB =
+  if true:
+    if b: 7 else: 8
+  else: ord(b)
+
+let foo = if cond:
+            if b: T else: F
+          else: b
+
+let a =
+  [[aaadsfas, bbb],
+   [ccc, ddd]]
+
+let b = [
+  [aaa, bbb],
+  [ccc, ddd]
+]
+
+# bug #11616
+proc newRecordGen(ctx: Context; typ: TypRef): PNode =
+  result = nkTypeDef.t(
+    newId(typ.optSym.name, true, pragmas = [id(if typ.isUnion: "cUnion"
+                                               else: "cStruct")]),
+    empty(),
+    nkObjectTy.t(
+      empty(),
+      empty(),
+      nkRecList.t(
+        typ.recFields.map(newRecFieldGen))))
+
+proc f =
+  # doesn't break the code, but leaving indentation as is would be nice.
+  let x = if true: callingProcWhatever()
+          else: callingADifferentProc()