Skip to content

Commit

Permalink
Add test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbolliger authored and jad-hamza committed May 20, 2021
1 parent 0467edb commit a0a3ff8
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion frontends/benchmarks/imperative/valid/MutableTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,34 @@ object MutableTuple {
case class Foo(var value: BigInt)
case class Bar(var value: BigInt)

def t1(pair: (Foo, Bar)) = {
def t1(pair: (Foo, Bar)): BigInt = {
pair._1.value = 1
assert(pair._1.value == 1)
pair._2.value
}

def t2() = {
val pair = (Foo(1), Foo(2), Foo(3))
val secondFoo = pair._2
secondFoo.value = 4
assert(pair == (Foo(1), Foo(4), Foo(3)))
assert(pair._2.value == secondFoo.value)

pair._2.value = 6
assert(pair == (Foo(1), Foo(6), Foo(3)))
assert(pair._2.value == secondFoo.value)
}

def t3(): (Foo, Bar) = {
val bar = Bar(1)
val foo = Foo(2)
(foo, bar)
}

def t4() = {
val pair = t3()
pair._2.value = 100

assert(t1((pair._1, pair._2)) == 100)
}
}

0 comments on commit a0a3ff8

Please sign in to comment.