summary refs log tree commit diff stats
path: root/tests/compile
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-05-26 21:06:39 +0300
committerZahary Karadjov <zahary@gmail.com>2013-05-26 21:06:39 +0300
commit911e6e710f28f454cf8bc1bb493c1a28c4694b76 (patch)
treec1b4ca3a7fa14fa4aa3ec6b36bd85a693f511b46 /tests/compile
parent4ae4005f805c5b2e329b2e060fcf40169238a9f9 (diff)
downloadNim-911e6e710f28f454cf8bc1bb493c1a28c4694b76.tar.gz
more test made green
the lambda lifting was trying too hard to ignore generic prods
isGenericRoutine was producing false-negatives and only
this allowed for some of the warning and error messages
to be triggered.

some files with mixed line endings were fixed
Diffstat (limited to 'tests/compile')
-rw-r--r--tests/compile/tobjects.nim86
-rw-r--r--tests/compile/toverprc.nim55
2 files changed, 71 insertions, 70 deletions
diff --git a/tests/compile/tobjects.nim b/tests/compile/tobjects.nim
index 68705d944..06fa15583 100644
--- a/tests/compile/tobjects.nim
+++ b/tests/compile/tobjects.nim
@@ -1,52 +1,52 @@
-type

-  TBase = object of TObject

-    x, y: int

-

-  TSubclassKind = enum ka, kb, kc, kd, ke, kf

-  TSubclass = object of TBase

-    case c: TSubclassKind

-    of ka, kb, kc, kd:

-      a, b: int

-    of ke:

-      d, e, f: char

-    else: nil

-    n: bool

+type
+  TBase = object of TObject
+    x, y: int
+
+  TSubclassKind = enum ka, kb, kc, kd, ke, kf
+  TSubclass = object of TBase
+    case c: TSubclassKind
+    of ka, kb, kc, kd:
+      a, b: int
+    of ke:
+      d, e, f: char
+    else: nil
+    n: bool
 
 type
   TMyObject = object of TObject
-    case disp: range[0..4]:
+    case disp: range[0..4]
       of 0: arg: char
       of 1: s: string
       else: wtf: bool
       
 var
   x: TMyObject
-

-var

-  global: int

-

-var

-  s: string

-  r: float = 0.0

-  i: int = 500 + 400

-

-case i

-of 500..999: write(stdout, "ha!\n")

-of 1000..3000, 12: write(stdout, "ganz schön groß\n")

-of 1, 2, 3: write(stdout, "1 2 oder 3\n")

-else: write(stdout, "sollte nicht passieren\n")

-

-case readLine(stdin)

-of "Rumpf": write(stdout, "Hallo Meister!\n")

-of "Andreas": write(stdout, "Hallo Meister!\n")

-else: write(stdout, "Nicht mein Meister!\n")

-

-global = global + 1

-write(stdout, "Hallo wie heißt du? \n")

-s = readLine(stdin)

-i = 0

-while i < len(s):

-  if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")

-  i = i + 1

-

-write(stdout, "Du heißt " & s)

+
+var
+  global: int
+
+var
+  s: string
+  r: float = 0.0
+  i: int = 500 + 400
+
+case i
+of 500..999: write(stdout, "ha!\n")
+of 1000..3000, 12: write(stdout, "ganz schön groß\n")
+of 1, 2, 3: write(stdout, "1 2 oder 3\n")
+else: write(stdout, "sollte nicht passieren\n")
+
+case readLine(stdin)
+of "Rumpf": write(stdout, "Hallo Meister!\n")
+of "Andreas": write(stdout, "Hallo Meister!\n")
+else: write(stdout, "Nicht mein Meister!\n")
+
+global = global + 1
+write(stdout, "Hallo wie heißt du? \n")
+s = readLine(stdin)
+i = 0
+while i < len(s):
+  if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")
+  i = i + 1
+
+write(stdout, "Du heißt " & s)
diff --git a/tests/compile/toverprc.nim b/tests/compile/toverprc.nim
index 467dd36c3..6d75fdf78 100644
--- a/tests/compile/toverprc.nim
+++ b/tests/compile/toverprc.nim
@@ -1,30 +1,30 @@
-# Test overloading of procs when used as function pointers

-

-import strutils

-

-proc parseInt(x: float): int {.noSideEffect.} = nil

-proc parseInt(x: bool): int {.noSideEffect.} = nil

-proc parseInt(x: float32): int {.noSideEffect.} = nil

-proc parseInt(x: int8): int {.noSideEffect.} = nil

-proc parseInt(x: TFile): int {.noSideEffect.} = nil

-proc parseInt(x: char): int {.noSideEffect.} = nil

-proc parseInt(x: int16): int {.noSideEffect.} = nil

-

-type

-  TParseInt = proc (x: string): int {.noSideEffect.}

-

-var

-  q = TParseInt(parseInt)

-  p: TParseInt = parseInt

-

-proc takeParseInt(x: proc (y: string): int {.noSideEffect.}): int = 

-  result = x("123")

-  

-echo "Give a list of numbers (separated by spaces): "

-var x = stdin.readline.split.map(parseInt).max

-echo x, " is the maximum!"

-echo "another number: ", takeParseInt(parseInt)

-

+# Test overloading of procs when used as function pointers
+
+import strutils
+
+proc parseInt(x: float): int {.noSideEffect.} = nil
+proc parseInt(x: bool): int {.noSideEffect.} = nil
+proc parseInt(x: float32): int {.noSideEffect.} = nil
+proc parseInt(x: int8): int {.noSideEffect.} = nil
+proc parseInt(x: TFile): int {.noSideEffect.} = nil
+proc parseInt(x: char): int {.noSideEffect.} = nil
+proc parseInt(x: int16): int {.noSideEffect.} = nil
+
+type
+  TParseInt = proc (x: string): int {.noSideEffect.}
+
+var
+  q = TParseInt(parseInt)
+  p: TParseInt = parseInt
+
+proc takeParseInt(x: proc (y: string): int {.noSideEffect.}): int = 
+  result = x("123")
+  
+echo "Give a list of numbers (separated by spaces): "
+var x = stdin.readline.split.map(parseInt).max
+echo x, " is the maximum!"
+echo "another number: ", takeParseInt(parseInt)
+
 
 type
   TFoo[a,b] = object
@@ -33,3 +33,4 @@ type
 
 proc bar[a,b](f: TFoo[a,b], x: a) = echo(x, " ", f.lorem, f.ipsum)
 proc bar[a,b](f: TFoo[a,b], x: b) = echo(x, " ", f.lorem, f.ipsum)
+