summary refs log tree commit diff stats
path: root/tests/method
diff options
context:
space:
mode:
Diffstat (limited to 'tests/method')
-rw-r--r--tests/method/mmultim3.nim2
-rw-r--r--tests/method/temptybody.nim2
-rw-r--r--tests/method/tmapper.nim30
-rw-r--r--tests/method/tmethods1.nim8
-rw-r--r--tests/method/tmproto.nim2
-rw-r--r--tests/method/tmultim1.nim6
-rw-r--r--tests/method/tmultim2.nim6
-rw-r--r--tests/method/tmultim4.nim4
-rw-r--r--tests/method/tmultim6.nim6
-rw-r--r--tests/method/trecmeth.nim8
10 files changed, 52 insertions, 22 deletions
diff --git a/tests/method/mmultim3.nim b/tests/method/mmultim3.nim
index 3139a8089..b391731be 100644
--- a/tests/method/mmultim3.nim
+++ b/tests/method/mmultim3.nim
@@ -3,7 +3,7 @@ type
 
 var myObj* : ref TObj
 
-method test123(a : ref TObj) =
+method test123(a : ref TObj) {.base.} =
     echo("Hi base!")
 
 proc testMyObj*() =
diff --git a/tests/method/temptybody.nim b/tests/method/temptybody.nim
index 26285d05b..aad945f81 100644
--- a/tests/method/temptybody.nim
+++ b/tests/method/temptybody.nim
@@ -2,7 +2,7 @@
 
 type MyClass = ref object of RootObj
 
-method HelloWorld*(obj: MyClass) =
+method HelloWorld*(obj: MyClass) {.base.} =
   when defined(myPragma):
     echo("Hello World")
   # discard # with this line enabled it works
diff --git a/tests/method/tmapper.nim b/tests/method/tmapper.nim
new file mode 100644
index 000000000..75b36e69a
--- /dev/null
+++ b/tests/method/tmapper.nim
@@ -0,0 +1,30 @@
+discard """
+  errormsg: "invalid declaration order; cannot attach 'step' to method defined here: tests/method/tmapper.nim(22,7)"
+  line: 25
+"""
+
+# bug #2590
+
+type
+  Console* = ref object
+    mapper*: Mapper
+
+  Mapper* = ref object of RootObj
+
+  Mapper2* = ref object of Mapper
+
+proc newMapper2*: Mapper2 =
+  new result
+
+proc newMapper*: Mapper =
+  result = newMapper2()
+
+method step*(m: Mapper2) {.base.} =
+  echo "Mapper2"
+
+method step*(m: Mapper) {.base.} =
+  echo "Mapper"
+
+var console = Console()
+console.mapper = newMapper()
+console.mapper.step()
diff --git a/tests/method/tmethods1.nim b/tests/method/tmethods1.nim
index 43a260bca..cb4da5ef2 100644
--- a/tests/method/tmethods1.nim
+++ b/tests/method/tmethods1.nim
@@ -2,7 +2,7 @@ discard """
   output: "do nothing"
 """
 
-method somethin(obj: TObject) =
+method somethin(obj: RootObj) {.base.} =
   echo "do nothing"
 
 type
@@ -11,12 +11,12 @@ type
 
   PNodeFoo* = ref object of TNode
 
-  TSomethingElse = object 
+  TSomethingElse = object
   PSomethingElse = ref TSomethingElse
 
-method foo(a: PNode, b: PSomethingElse) = discard
+method foo(a: PNode, b: PSomethingElse) {.base.} = discard
 method foo(a: PNodeFoo, b: PSomethingElse) = discard
 
-var o: TObject
+var o: RootObj
 o.somethin()
 
diff --git a/tests/method/tmproto.nim b/tests/method/tmproto.nim
index 5d75cff1a..087666ea0 100644
--- a/tests/method/tmproto.nim
+++ b/tests/method/tmproto.nim
@@ -2,7 +2,7 @@ type
   Obj1 = ref object {.inheritable.}
   Obj2 = ref object of Obj1
 
-method beta(x: Obj1): int
+method beta(x: Obj1): int {.base.}
 
 proc delta(x: Obj2): int =
   beta(x)
diff --git a/tests/method/tmultim1.nim b/tests/method/tmultim1.nim
index 7f551aa64..010468a5b 100644
--- a/tests/method/tmultim1.nim
+++ b/tests/method/tmultim1.nim
@@ -10,15 +10,15 @@ type
     x: int
   PlusExpr = ref object of Expression
     a, b: Expression
-    
-method eval(e: Expression): int = quit "to override!"
+
+method eval(e: Expression): int {.base.} = quit "to override!"
 method eval(e: Literal): int = return e.x
 method eval(e: PlusExpr): int = return eval(e.a) + eval(e.b)
 
 proc newLit(x: int): Literal =
   new(result)
   result.x = x
-  
+
 proc newPlus(a, b: Expression): PlusExpr =
   new(result)
   result.a = a
diff --git a/tests/method/tmultim2.nim b/tests/method/tmultim2.nim
index c5fb568a0..98a08b1cb 100644
--- a/tests/method/tmultim2.nim
+++ b/tests/method/tmultim2.nim
@@ -13,10 +13,10 @@ type
     x: int
   TParticle = object of TThing
     a, b: int
-    
-method collide(a, b: TThing) {.inline.} =
+
+method collide(a, b: TThing) {.base, inline.} =
   echo "collide: thing, thing"
-  
+
 method collide(a: TThing, b: TUnit) {.inline.} =
   echo "collide: thing, unit"
 
diff --git a/tests/method/tmultim4.nim b/tests/method/tmultim4.nim
index d824086b2..eabf8d126 100644
--- a/tests/method/tmultim4.nim
+++ b/tests/method/tmultim4.nim
@@ -5,7 +5,7 @@ discard """
 type
   Test = object of TObject
 
-method doMethod(a: ref TObject) {.raises: [EIO].} =
+method doMethod(a: ref TObject) {.base, raises: [EIO].} =
   quit "override"
 
 method doMethod(a: ref Test) =
@@ -26,7 +26,7 @@ var s:ref Test = newTest()
 for z in 1..4:
   s.doMethod()
   break
- 
+
 #works
 #for z in 1..4:
 #  s.doProc()
diff --git a/tests/method/tmultim6.nim b/tests/method/tmultim6.nim
index 5f45f572a..97ed2845c 100644
--- a/tests/method/tmultim6.nim
+++ b/tests/method/tmultim6.nim
@@ -9,10 +9,10 @@ type
     x: T
   TParticle = object of TThing
     a, b: int
-    
-method collide(a, b: TThing) {.inline.} =
+
+method collide(a, b: TThing) {.base, inline.} =
   quit "to override!"
-  
+
 method collide[T](a: TThing, b: TUnit[T]) {.inline.} =
   write stdout, "collide: thing, unit | "
 
diff --git a/tests/method/trecmeth.nim b/tests/method/trecmeth.nim
index 32f620f15..ac0a1e977 100644
--- a/tests/method/trecmeth.nim
+++ b/tests/method/trecmeth.nim
@@ -2,12 +2,12 @@
 # for recursive methods works, no code is being executed
 
 type
-  Obj = ref object of TObject
+  Obj = ref object of RootObj
 
 # Mutual recursion
 
-method alpha(x: Obj)
-method beta(x: Obj)
+method alpha(x: Obj) {.base.}
+method beta(x: Obj) {.base.}
 
 method alpha(x: Obj) =
   beta(x)
@@ -17,6 +17,6 @@ method beta(x: Obj) =
 
 # Simple recursion
 
-method gamma(x: Obj) =
+method gamma(x: Obj) {.base.} =
   gamma(x)