@@ -31,3 +31,59 @@ object Test:
31
31
// again, the lub of :: and Nil is Product, which breaks ++ (which requires IterableOnce)
32
32
def lub2 (b : Boolean ): Unit =
33
33
Seq (1 ) ++ (if (b) Seq (2 ) else Nil )
34
+
35
+ // Examples of arity and nesting arity
36
+ // to find the thresholds and reproduce the behaviour of nsc
37
+ // tested manually, comparing -Xprint across compilers (ran out of time)
38
+ def examples (): Unit =
39
+ val max1 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , " 6" , " 7" ) // 7 cons w/ 7 string heads + nil
40
+ val max2 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , " 6" , List [Object ]()) // 7 cons w/ 6 string heads + 1 nil head + nil
41
+ val max3 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , List [Object ](" 6" ))
42
+ val max4 = List [Object ](" 1" , " 2" , " 3" , " 4" , List [Object ](" 5" , " 6" ))
43
+
44
+ val over1 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , " 6" , " 7" , " 8" ) // wrap 8-sized array
45
+ val over2 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , " 6" , " 7" , List [Object ]()) // wrap 8-sized array
46
+ val over3 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , " 6" , List [Object ](" 7" )) // wrap 1-sized array with 7
47
+ val over4 = List [Object ](" 1" , " 2" , " 3" , " 4" , " 5" , List [Object ](" 6" , " 7" )) // wrap 2
48
+
49
+ val max5 =
50
+ List [Object ](
51
+ List [Object ](
52
+ List [Object ](
53
+ List [Object ](
54
+ List [Object ](
55
+ List [Object ](
56
+ List [Object ](
57
+ List [Object ](
58
+ )))))))) // 7 cons + 1 nil
59
+
60
+ val over5 =
61
+ List [Object ](
62
+ List [Object ](
63
+ List [Object ](
64
+ List [Object ](
65
+ List [Object ](
66
+ List [Object ](
67
+ List [Object ](
68
+ List [Object ]( List [Object ]()
69
+ )))))))) // 7 cons + 1-sized array wrapping nil
70
+
71
+ val max6 =
72
+ List [Object ]( // ::(
73
+ " 1" , " 2" , List [Object ]( // 1, ::(2, ::(::(
74
+ " 3" , " 4" , List [Object ]( // 3, ::(4, ::(::(
75
+ List [Object ]() // Nil, Nil
76
+ ) // ), Nil))
77
+ ) // ), Nil))
78
+ ) // )
79
+ // 7 cons + 4 string heads + 4 nils for nested lists
80
+
81
+ val max7 =
82
+ List [Object ]( // ::(
83
+ " 1" , " 2" , List [Object ]( // 1, ::(2, ::(::(
84
+ " 3" , " 4" , List [Object ]( // 3, ::(4, ::(::(
85
+ " 5" // 5, Nil
86
+ ) // ), Nil))
87
+ ) // ), Nil))
88
+ ) // )
89
+ // 7 cons + 5 string heads + 3 nils for nested lists
0 commit comments