From 2166b7bc46419a78b9e22062959e7272dfb89692 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Thu, 15 Oct 2015 15:00:30 +0300 Subject: Fixed ret by var in js --- tests/testament/categories.nim | 4 +++- tests/varres/tvarres0.nim | 30 ++++++++++++++++++++++++++++++ tests/varres/tvartup.nim | 6 +----- 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 tests/varres/tvarres0.nim (limited to 'tests') 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 - - -- cgit 1.4.1-2-gfad0