"Fossies" - the Fresh Open Source Software Archive

Member "scala-js-1.3.1/test-suite/shared/src/test/require-scala2/org/scalajs/testsuite/scalalib/ArrayBuilderTestScala2.scala" (14 Nov 2020, 1481 Bytes) of package /linux/www/scala-js-1.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scala source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Scala.js (https://www.scala-js.org/)
    3  *
    4  * Copyright EPFL.
    5  *
    6  * Licensed under Apache License 2.0
    7  * (https://www.apache.org/licenses/LICENSE-2.0).
    8  *
    9  * See the NOTICE file distributed with this work for
   10  * additional information regarding copyright ownership.
   11  */
   12 
   13 package org.scalajs.testsuite.scalalib
   14 
   15 import scala.reflect.ClassTag
   16 import scala.collection.mutable.ArrayBuilder
   17 
   18 import org.junit.Test
   19 import org.junit.Assert.assertSame
   20 
   21 class ArrayBuilderTestScala2 {
   22 
   23   @inline
   24   def makeNoInline[T](implicit ct: ClassTag[T]): ArrayBuilder[T] = {
   25     /* The dance in this method is to be source compatible with the old and
   26      * new collections. In the new collections, ArrayBuilder.make[T] doesn't
   27      * take an explicit () parameter list, but it does in the old collections.
   28      */
   29 
   30     @noinline def ctNoInline = ct
   31 
   32     {
   33       implicit val ct = ctNoInline
   34       ArrayBuilder.make[T]
   35     }
   36   }
   37 
   38   /**
   39    * This is a Scala 2.x only test because:
   40    * Dotty does not have [[ClassTag]] instances for [[Nothing]] or for [[Null]].
   41    * @see [[https://github.com/lampepfl/dotty/issues/1730]]
   42    */
   43   @Test def Nothing_and_Null(): Unit = {
   44     assertSame(classOf[Array[Nothing]], ArrayBuilder.make[Nothing].result().getClass)
   45     assertSame(classOf[Array[Null]], ArrayBuilder.make[Null].result().getClass)
   46 
   47     assertSame(classOf[Array[Nothing]], makeNoInline[Nothing].result().getClass)
   48     assertSame(classOf[Array[Null]], makeNoInline[Null].result().getClass)
   49   }
   50 }