Skip to content

Commit

Permalink
Switch to scala 3 import style
Browse files Browse the repository at this point in the history
  • Loading branch information
lukestephenson-zendesk committed Oct 6, 2023
1 parent 2d4ebdf commit dab8e89
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ sbt> console
Once in the console, you can import your production code as such:

```
import package.objectname._
import package.objectname.*
```

For example, to use functions defined in _introcourse.level01.IntroExercises_:

```
scala> import introcourse.level01.IntroExercises._
scala> import introcourse.level01.IntroExercises.*
scala> add(1, 2)
res0: Int = 3
```
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/introcourse/level06/Try.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def evenE(n: Int): Either[String, Int] = if (n % 2 == 0) Right(n) else Left (s"$
```

```scala
import scala.util._
import scala.util.*

def evenT(n: Int): Try[Int] = if (n % 2 == 0) Success(n) else Failure (new RuntimeException(s"$n is not even"))
```
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/introcourse/level06/TryExercises.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ object TryExercises {
case class Employee()

/**
* Now remove `import TryTestTypes._` from `TryExercisesTest.scala`
* Now remove `import TryTestTypes.*` from `TryExercisesTest.scala`
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/introcourse/level07/LogParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object LogParser {
}

/**
* Once you have defined your data types, remove `import Types._` from
* Once you have defined your data types, remove `import Types.*` from
* [LogParserTest.scala](src/test/scala/introcourse/level07/LogParserTest.scala)
*/

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/introcourse/level07/Main.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package introcourse.level07

import scala.io.Source
import LogParser._
import LogParser.*

/**
* The `main` method does the following:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package introcourse.level01

import introcourse.level01.IntroExercises._
import introcourse.level01.IntroExercises.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/introcourse/level03/ListExercisesTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package introcourse.level03

import introcourse.level03.ListExercises._
import introcourse.level03.ListExercises.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package introcourse.level04

import introcourse.level04.OptionExercises2._
import introcourse.level04.OptionExercises2.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package introcourse.level04

import introcourse.level04.OptionExercises2.Job
import introcourse.level04.OptionExercises3._
import introcourse.level04.OptionExercises3.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package introcourse.level05

import introcourse.level05.ExceptionExercises._
import introcourse.level05.ExceptionExercises.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

Expand Down
5 changes: 2 additions & 3 deletions src/test/scala/introcourse/level06/TryExercisesTest.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package introcourse.level06

import introcourse.level06.TryExercises._

import introcourse.level06.TryExercises.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

import scala.util.{Failure, Success}

class TryExercisesTest extends AnyFunSpec with TypeCheckedTripleEquals {
// TODO: Remove this import once you've defined Employee data type in TryExercuses
import TryTestTypes._
import TryTestTypes.*

describe("parseIntSafe") {

Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/introcourse/level06/TryTestTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package introcourse.level06

/**
* This file exists just to get the type-safe tests in `TryExercisesTest.scala` to compile.
* Once you have defined the `Employee` type in `TryExercises.scala`, remove `import TryTestTypes._`
* Once you have defined the `Employee` type in `TryExercises.scala`, remove `import TryTestTypes.*`
* from `TryExercisesTest.scala`.
*/
object TryTestTypes {
private def undefinedInTry: Nothing =
throw new RuntimeException("Please remove `import TryTestTypes._` from `TryExercisesTest.scala`")
throw new RuntimeException("Please remove `import TryTestTypes.*` from `TryExercisesTest.scala`")

def Employee(args: Any*): Nothing = undefinedInTry
}
4 changes: 2 additions & 2 deletions src/test/scala/introcourse/level07/LogParserTest.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package introcourse.level07

import introcourse.level07.LogParser._
import introcourse.level07.LogParser.*
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.funspec.AnyFunSpec

class LogParserTest extends AnyFunSpec with TypeCheckedTripleEquals {
// TODO: Remove this import once you've defined the ADTs in LogParser
import Types._
import Types.*

describe("parseIntOption") {
it("should return the parsed integer for a valid integer") {
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/introcourse/level07/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package introcourse.level07

/**
* This file exists just to get the type-safe tests in `LogParserTests.scala` to compile.
* Once the ADTs are defined in `LogParser.scala`, remove `import Types._` from `LogParserTests.scala`.
* Once the ADTs are defined in `LogParser.scala`, remove `import Types.*` from `LogParserTests.scala`.
*/
object Types {
private def undefinedInLogParser: Nothing =
throw new RuntimeException("Please remove `import Types._` from `LogParserTests.scala`")
throw new RuntimeException("Please remove `import Types.*` from `LogParserTests.scala`")

def Info: Nothing = undefinedInLogParser
def Warning: Nothing = undefinedInLogParser
Expand Down

0 comments on commit dab8e89

Please sign in to comment.