summaryrefslogtreecommitdiff
path: root/test/files/run/var-arity-class-symbol.scala
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-01-22 13:43:50 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-01-22 14:06:30 +0100
commitca74550416049f106e4770edba70be918d674d7f (patch)
tree27785d4d1bbb547fd0f46f1565f7e37e3ff4cc8b /test/files/run/var-arity-class-symbol.scala
parent115cd16aca35c8b4000b86f4affd4df243202fd2 (diff)
downloadscala-ca74550416049f106e4770edba70be918d674d7f.tar.gz
scala-ca74550416049f106e4770edba70be918d674d7f.tar.bz2
scala-ca74550416049f106e4770edba70be918d674d7f.zip
Expose seq field for variable arity definitions
In 2.11 we've changed TupleClass, ProductClass and FunctionClass endpoints to be exposed as (Int => Symbol) functions that never throw exceptions but rather return NoSymbol instead of previous error-prone indexed access on array that could explode. While simplifying one use case (indexed access) it complicated ability to check if symbol at hand is in fact a tuple, product or function: (1 to 22).map(TupleClass).toList.contains(symbol) To cover this extra use case we add a seq method to the variable arity class definitions that exposes a corresponding sequence of class symbols: TupleClass.seq.contains(symbol)
Diffstat (limited to 'test/files/run/var-arity-class-symbol.scala')
-rw-r--r--test/files/run/var-arity-class-symbol.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/run/var-arity-class-symbol.scala b/test/files/run/var-arity-class-symbol.scala
new file mode 100644
index 0000000000..29fe960eb3
--- /dev/null
+++ b/test/files/run/var-arity-class-symbol.scala
@@ -0,0 +1,19 @@
+import scala.reflect.runtime.universe._, definitions._
+object Test extends App {
+ // Tuples
+ assert(TupleClass.seq.size == 22)
+ assert(TupleClass(0) == NoSymbol)
+ assert(TupleClass(23) == NoSymbol)
+ assert((1 to 22).forall { i => TupleClass(i).name.toString == s"Tuple$i" })
+ // Functions
+ assert(FunctionClass.seq.size == 23)
+ assert(FunctionClass(-1) == NoSymbol)
+ assert(FunctionClass(23) == NoSymbol)
+ assert((0 to 22).forall { i => FunctionClass(i).name.toString == s"Function$i" })
+ // Products
+ assert(ProductClass.seq.size == 23)
+ assert(ProductClass(-1) == NoSymbol)
+ assert(ProductClass(0) == UnitClass)
+ assert(ProductClass(23) == NoSymbol)
+ assert((1 to 22).forall { i => ProductClass(i).name.toString == s"Product$i" })
+}