File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
scala-core-modules/scala-core-9/src/test/scala/com/baeldung/scala/rootimport Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .baeldung .scala .rootimport
2
+
3
+ import org .scalatest .flatspec .AnyFlatSpec
4
+
5
+ class RootImportUnitTest extends AnyFlatSpec {
6
+
7
+ it should " use the custom List when using relative import" in {
8
+ import scala .*
9
+ val myList : scala.List = List (100 )
10
+ assert(myList.toString == " MyList[100]" )
11
+ }
12
+
13
+ it should " use the scala collection List when using root import" in {
14
+ import _root_ .scala .*
15
+ val scalaList : List [Int ] = List (100 )
16
+ assert(scalaList.toString == " List(100)" )
17
+ }
18
+
19
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .scala .rootimport .scala
2
+
3
+ class List (val num : Int ) {
4
+ override def toString : String = s " MyList[ ${num}] "
5
+ }
6
+
7
+ object List {
8
+ def apply (num : Int ) = new List (num)
9
+ }
You can’t perform that action at this time.
0 commit comments