aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/pickleOK/nameddefaults.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-05 15:56:43 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:15 +0100
commit35d1160cd65d21076b1f640624663ad7b35f9c56 (patch)
treee6dd003c59002bb31a96f0dc357ee1f5ef84188d /tests/pos/pickleOK/nameddefaults.scala
parent3823f29c05cb071cd3a595751543021a4f4cf382 (diff)
downloaddotty-35d1160cd65d21076b1f640624663ad7b35f9c56.tar.gz
dotty-35d1160cd65d21076b1f640624663ad7b35f9c56.tar.bz2
dotty-35d1160cd65d21076b1f640624663ad7b35f9c56.zip
More tests
Both some long overdue pos tests and more pickleOK tests
Diffstat (limited to 'tests/pos/pickleOK/nameddefaults.scala')
-rw-r--r--tests/pos/pickleOK/nameddefaults.scala63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/pos/pickleOK/nameddefaults.scala b/tests/pos/pickleOK/nameddefaults.scala
new file mode 100644
index 000000000..671f14a07
--- /dev/null
+++ b/tests/pos/pickleOK/nameddefaults.scala
@@ -0,0 +1,63 @@
+object nameddefaults {
+
+ def foo(first: Int, second: Int = 2, third: Int = 3) = first + second
+
+ var x = 1
+ var y = 2
+
+ foo(1, 2, 3)
+
+ foo(1, 2)
+
+ foo(1)
+
+ // named and missing arguments
+
+ foo(first = 1, second = 3)
+
+ foo(second = 3, first = 1)
+
+ foo(first = 2, third = 3)
+
+ foo(2, third = 3)
+
+ // same but with non-idempotent expressions
+
+ foo(first = x, second = y)
+
+ foo(second = x, first = y)
+
+ foo(first = x, third = y)
+
+ foo(x, third = y)
+
+// The same thing, but for classes
+
+ class C(first: Int, second: Int = 2, third: Int = 3) {}
+
+ new C(1, 2, 3)
+
+ new C(1, 2)
+
+ new C(1)
+
+ // named and missing arguments
+
+ new C(first = 1, second = 3)
+
+ new C(second = 3, first = 1)
+
+ new C(first = 2, third = 3)
+
+ new C(2, third = 3)
+
+ // same but with non-idempotent expressions
+
+ new C(first = x, second = y)
+
+ new C(second = x, first = y)
+
+ new C(first = x, third = y)
+
+
+}