Skip to content

Commit a0a3ff8

Browse files
yannbolligerjad-hamza
authored andcommitted
Add test cases.
1 parent 0467edb commit a0a3ff8

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

frontends/benchmarks/imperative/valid/MutableTuple.scala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,34 @@ object MutableTuple {
55
case class Foo(var value: BigInt)
66
case class Bar(var value: BigInt)
77

8-
def t1(pair: (Foo, Bar)) = {
8+
def t1(pair: (Foo, Bar)): BigInt = {
99
pair._1.value = 1
1010
assert(pair._1.value == 1)
11+
pair._2.value
12+
}
13+
14+
def t2() = {
15+
val pair = (Foo(1), Foo(2), Foo(3))
16+
val secondFoo = pair._2
17+
secondFoo.value = 4
18+
assert(pair == (Foo(1), Foo(4), Foo(3)))
19+
assert(pair._2.value == secondFoo.value)
20+
21+
pair._2.value = 6
22+
assert(pair == (Foo(1), Foo(6), Foo(3)))
23+
assert(pair._2.value == secondFoo.value)
24+
}
25+
26+
def t3(): (Foo, Bar) = {
27+
val bar = Bar(1)
28+
val foo = Foo(2)
29+
(foo, bar)
30+
}
31+
32+
def t4() = {
33+
val pair = t3()
34+
pair._2.value = 100
35+
36+
assert(t1((pair._1, pair._2)) == 100)
1137
}
1238
}

0 commit comments

Comments
 (0)