"Fossies" - the Fresh Open Source Software Archive

Member "scala-js-1.0.0-RC1/test-suite/js/src/test/scala-old-collections/org/scalajs/testsuite/library/ArrayOpsCollectionEraDependentTest.scala" (21 Nov 2019, 1455 Bytes) of package /linux/www/scala-js-1.0.0-RC1.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.library
   14 
   15 import scala.scalajs.js
   16 
   17 import org.junit.Assert._
   18 import org.junit.Test
   19 
   20 class ArrayOpsCollectionEraDependentTest {
   21 
   22   @Test def apply(): Unit = {
   23     val array = js.Array(3, 4, 5, 6, 3, 4)
   24     val ops: js.ArrayOps[Int] = array
   25 
   26     assertEquals(3, ops(0))
   27     assertEquals(6, ops(3))
   28 
   29     array(0) = 4
   30     assertEquals(4, ops(0))
   31   }
   32 
   33   @Test def update(): Unit = {
   34     val array = js.Array(3, 4, 5, 6, 3, 4)
   35     val ops: js.ArrayOps[Int] = array
   36 
   37     assertEquals(4, array(1))
   38     ops(1) = 5
   39     assertEquals(5, array(1))
   40 
   41     ops(5) = 10
   42     assertEquals(10, array(5))
   43   }
   44 
   45   @Test def length(): Unit = {
   46     val array = js.Array(3, 4, 5, 6, 3, 4)
   47     val ops: js.ArrayOps[Int] = array
   48 
   49     assertEquals(6, ops.length)
   50     array.push(1)
   51     assertEquals(7, ops.length)
   52   }
   53 
   54   @Test def seq(): Unit = {
   55     val array = js.Array(3, 4, 5, 6, 3, 4)
   56     val ops: js.ArrayOps[Int] = array
   57     val seq = ops.seq
   58 
   59     assertEquals(List(3, 4, 5, 6, 3, 4), seq.toList)
   60   }
   61 
   62   @Test def to_T_issue_843(): Unit = {
   63     val array = js.Array(1, 2, 1, 3, 1, 10, 9)
   64     val list = array.to[List]
   65     assertArrayEquals(array.toArray, list.toArray)
   66   }
   67 
   68 }