summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorYuriy Glukhov <yuriy.glukhov@gmail.com>2015-10-15 15:00:30 +0300
committerYuriy Glukhov <yuriy.glukhov@gmail.com>2015-10-15 16:04:53 +0300
commit2166b7bc46419a78b9e22062959e7272dfb89692 (patch)
treed7e549a43d8b1f8a30fb5df429f213858c4fb07e /tests
parentc97cbe7abd85d134e95ad1a7044fc314c60e5bed (diff)
downloadNim-2166b7bc46419a78b9e22062959e7272dfb89692.tar.gz
Fixed ret by var in js
Diffstat (limited to 'tests')
-rw-r--r--tests/testament/categories.nim4
-rw-r--r--tests/varres/tvarres0.nim30
-rw-r--r--tests/varres/tvartup.nim6
3 files changed, 34 insertions, 6 deletions
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 3bb18d8a2..e700ff185 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -216,7 +216,9 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
                    "exception/texcsub", "exception/tfinally",
                    "exception/tfinally2", "exception/tfinally3",
                    "actiontable/tactiontable", "method/tmultim1",
-                   "method/tmultim3", "method/tmultim4"]:
+                   "method/tmultim3", "method/tmultim4",
+                   "varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
+                   "varres/tvartup"]:
     test "tests/" & testfile & ".nim"
 
 # ------------------------- manyloc -------------------------------------------
diff --git a/tests/varres/tvarres0.nim b/tests/varres/tvarres0.nim
new file mode 100644
index 000000000..fd10a73bd
--- /dev/null
+++ b/tests/varres/tvarres0.nim
@@ -0,0 +1,30 @@
+discard """
+  output: '''123
+1234
+123
+1234
+12345
+'''
+"""
+
+# Test simple type
+var a = 123
+proc getA(): var int = a
+
+echo getA()
+
+getA() = 1234
+echo getA()
+
+
+# Test object type
+type Foo = object
+    a: int
+var f: Foo
+f.a = 123
+proc getF(): var Foo = f
+echo getF().a
+getF().a = 1234
+echo getF().a
+getF() = Foo(a: 12345)
+echo getF().a
diff --git a/tests/varres/tvartup.nim b/tests/varres/tvartup.nim
index 20a4156e6..1957a3e35 100644
--- a/tests/varres/tvartup.nim
+++ b/tests/varres/tvartup.nim
@@ -8,10 +8,6 @@ proc divmod(a, b: int): tuple[di, mo: int] =
   return (a div b, a mod b)
 
 var (x, y) = divmod(15, 6)
-stdout.write(x)
-stdout.write(" ")
-stdout.write(y)
+echo x, " ", y
 
 #OUT 2 3
-
-