Skip to content

Commit 2efc0dd

Browse files
committed
Adapt test to 2.12.x
1 parent 0821625 commit 2efc0dd

File tree

5 files changed

+47
-21
lines changed

5 files changed

+47
-21
lines changed

tests/neg/t5729.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ object Test {
66
}
77

88
object C {
9-
def join(in: Seq[List[_]]): Int = error("TODO")
10-
def join[S](in: Seq[List[S]]): String = error("TODO")
9+
def join(in: Seq[List[_]]): Int = sys.error("TODO")
10+
def join[S](in: Seq[List[S]]): String = sys.error("TODO")
1111

1212
join(Seq[List[Int]]()) // error: ambiguous
1313
//

tests/run/t6634.check

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ String OK.
44
Length OK.
55

66
Trying lb1 ...
7+
java.lang.IndexOutOfBoundsException: at 6 deleting 6
78
Checking ...
89
String OK.
910
Length OK.
1011

1112
Trying lb2 ...
13+
java.lang.IndexOutOfBoundsException: at 99 deleting 6
1214
Checking ...
1315
String OK.
1416
Length OK.
1517

1618
Trying lb3 ...
19+
java.lang.IndexOutOfBoundsException: at 1 deleting 9
1720
Checking ...
1821
String OK.
1922
Length OK.
2023

2124
Trying lb4 ...
25+
java.lang.IndexOutOfBoundsException: at -1 deleting 1
2226
Checking ...
2327
String OK.
2428
Length OK.
2529

2630
Trying lb5 ...
27-
java.lang.IllegalArgumentException: removing negative number (-1) of elements
31+
java.lang.IllegalArgumentException: removing negative number of elements: -1
2832
Checking ...
2933
String OK.
3034
Length OK.

tests/run/t6634.scala

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import collection.mutable.ListBuffer
22

3-
object Test extends dotty.runtime.LegacyApp {
3+
//object Test extends dotty.runtime.LegacyApp {
4+
object Test extends App {
45
def newLB = ListBuffer('a, 'b, 'c, 'd, 'e)
56

67
val lb0 = newLB
78
println("Trying lb0 ...")
89
try {
910
lb0.remove(5, 0)
1011
} catch {
11-
// Not thrown in 2.10, will be thrown in 2.11
12+
// Should not be thrown--nothing is deleted so nothing to do
1213
case ex: IndexOutOfBoundsException => println(ex)
1314
}
1415
checkNotCorrupted(lb0)
@@ -17,8 +18,8 @@ object Test extends dotty.runtime.LegacyApp {
1718
println("Trying lb1 ...")
1819
try {
1920
lb1.remove(6, 6)
20-
} catch {
21-
// Not thrown in 2.10, will be thrown in 2.11
21+
} catch {
22+
// Not thrown in 2.11, is thrown in 2.12
2223
case ex: IndexOutOfBoundsException => println(ex)
2324
}
2425
checkNotCorrupted(lb1)
@@ -28,7 +29,7 @@ object Test extends dotty.runtime.LegacyApp {
2829
try {
2930
lb2.remove(99, 6)
3031
} catch {
31-
// Not thrown in 2.10, will be thrown in 2.11
32+
// Not thrown in 2.11, is thrown in 2.12
3233
case ex: IndexOutOfBoundsException => println(ex)
3334
}
3435
checkNotCorrupted(lb2)
@@ -38,26 +39,27 @@ object Test extends dotty.runtime.LegacyApp {
3839
try {
3940
lb3.remove(1, 9)
4041
} catch {
41-
// Not thrown in 2.10, will be thrown in 2.11
42-
case ex: IllegalArgumentException => println(ex)
42+
// Not thrown in 2.11, is thrown in 2.12
43+
case ex: IndexOutOfBoundsException => println(ex)
4344
}
44-
checkNotCorrupted(lb3, "ListBuffer('a)", 1)
45+
checkNotCorrupted(lb3)
4546

4647
val lb4 = newLB
4748
println("Trying lb4 ...")
4849
try {
4950
lb4.remove(-1, 1)
5051
} catch {
51-
// Not thrown in 2.10, will be thrown in 2.11
52+
// Not thrown in 2.11, is thrown in 2.12
5253
case ex: IndexOutOfBoundsException => println(ex)
5354
}
54-
checkNotCorrupted(lb4, "ListBuffer('b, 'c, 'd, 'e)", 4)
55+
checkNotCorrupted(lb4)
5556

5657
val lb5 = newLB
5758
println("Trying lb5 ...")
5859
try {
5960
lb5.remove(1, -1)
6061
} catch {
62+
// Was thrown prior to 2.12 also
6163
case ex: IllegalArgumentException => println(ex)
6264
}
6365
checkNotCorrupted(lb5)

tests/run/t6827.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
start at -5: java.lang.IllegalArgumentException: requirement failed: start -5 out of range 10
2-
start at -1: java.lang.IllegalArgumentException: requirement failed: start -1 out of range 10
3-
start at limit: java.lang.IllegalArgumentException: requirement failed: start 10 out of range 10
1+
start at -5: java.lang.ArrayIndexOutOfBoundsException: -5
2+
start at -1: java.lang.ArrayIndexOutOfBoundsException: -1
3+
start at limit: ok
44
start at limit-1: ok
55
first 10: ok
66
read all: ok
77
test huge len: ok
88
5 from 5: ok
99
20 from 5: ok
1010
test len overflow: ok
11-
start beyond limit: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10
11+
start beyond limit: ok
1212
read 0: ok
1313
read -1: ok
14-
invalid read 0: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10
15-
invalid read -1: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10
14+
invalid read 0: ok
15+
invalid read -1: ok

tests/run/t6827.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
object Test extends dotty.runtime.LegacyApp {
1+
object Test extends App {
22
val ns = (0 until 20)
33
val arr = new Array[Int](10)
44

@@ -29,6 +29,26 @@ object Test extends dotty.runtime.LegacyApp {
2929
tryit("invalid read 0", 30, 0)
3030
tryit("invalid read -1", 30, -1)
3131

32-
// okay, see SI-7128
32+
// okay, see scala/bug#7128
3333
"...".toIterator.copyToArray(new Array[Char](0), 0, 0)
34+
35+
36+
// Bonus test from @som-snytt to check for overflow in
37+
// index calculations.
38+
def testOverflow(start: Int, len: Int, expected: List[Char]) = {
39+
def copyFromIterator = {
40+
val arr = Array.fill[Char](3)('-')
41+
"abc".toIterator.copyToArray(arr, start, len)
42+
arr.toList
43+
}
44+
def copyFromArray = {
45+
val arr = Array.fill[Char](3)('-')
46+
"abc".toArray.copyToArray(arr, start, len)
47+
arr.toList
48+
}
49+
assert(copyFromIterator == expected)
50+
assert(copyFromArray == expected)
51+
}
52+
testOverflow(1, Int.MaxValue - 1, "-ab".toList)
53+
testOverflow(1, Int.MaxValue, "-ab".toList)
3454
}

0 commit comments

Comments
 (0)