aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/desugar.scala13
-rw-r--r--tests/pos/nameddefaults.scala33
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/pos/desugar.scala b/tests/pos/desugar.scala
new file mode 100644
index 000000000..ffd114652
--- /dev/null
+++ b/tests/pos/desugar.scala
@@ -0,0 +1,13 @@
+object desugar {
+
+ // variables
+ var x: Int = 2
+ var y = x * x
+
+ { var z: Int = y }
+
+ def foo0(first: Int, second: Int = 2, third: Int = 3) = first + second
+ def foo1(first: Int, second: Int = 2)(third: Int = 3) = first + second
+ def foo2(first: Int)(second: Int = 2)(third: Int = 3) = first + second
+
+} \ No newline at end of file
diff --git a/tests/pos/nameddefaults.scala b/tests/pos/nameddefaults.scala
new file mode 100644
index 000000000..4c08e62ef
--- /dev/null
+++ b/tests/pos/nameddefaults.scala
@@ -0,0 +1,33 @@
+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)
+}