Skip to content

Update dependencies #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,8 @@ object OrderOfScotch {
val order1 = OrderOfScotch.builder.set(Brand, "Takes").set(IsDouble, true).
set(Glass, Some(Tall)).set(Mode, OnTheRocks).build()

// Point-free version of the above
val order2 = (OrderOfScotch.builder
set(Brand, "Takes")
set(IsDouble, true)
set(Glass, Some(Tall))
set(Mode, OnTheRocks)
build())

assert(order1 == OrderOfScotch("Takes", OnTheRocks, true, Some(Tall)),
"Time to get out the scotch...")

assert(order1 == order2, "Traditional and point-free build results should be identical")
}
}
```
Expand All @@ -128,7 +118,7 @@ For more examples, see the test specifications [here](https://github.com/harveyw

Prerequisites
--------------------------------
This library requires Scala 2.10 and shapeless 1.2.3.
This library requires Scala 2.12 and shapeless 2.3.3.

Scaladoc
--------------------------------
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ lazy val examples = (project
def commonSettings =
Seq(
organization := "org.aylasoftware",
scalaVersion := "2.12.10",
crossScalaVersions := Seq(scalaVersion.value, "2.10.7", "2.11.12", "2.13.1"),
scalaVersion := "2.13.4",
crossScalaVersions := Seq(scalaVersion.value, "2.12.12"),
scalacOptions := Seq(
"-feature",
"-language:higherKinds",
Expand All @@ -34,6 +34,6 @@ def commonSettings =

libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.3.3" withSources(),
"org.scalatest" %% "scalatest" % "3.1.0" % "test"
"org.scalatest" %% "scalatest" % "3.2.2" % "test"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package com.github.harveywi.builder

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.matchers.should.Matchers._
import shapeless._

object HasBuilderSpec {
Expand Down Expand Up @@ -93,7 +93,7 @@ object HasBuilderSpec {
}
}

class HasBuilderSpec extends AnyFlatSpec with Matchers {
class HasBuilderSpec extends AnyFlatSpec {
import HasBuilderSpec._
"When method chaining is not used, a builder for a case class with a single required parameter" should "generate the expected case class" in {
val expected = TestInt(42)
Expand Down Expand Up @@ -124,9 +124,6 @@ class HasBuilderSpec extends AnyFlatSpec with Matchers {

// Method chaining can be more succinct
TestInt.builder.set(X, 42).build() should equal(expected)

// Chaining using point-free style
TestInt.builder set (X, 42) build () should equal(expected)
}

// Try out the optional parameters
Expand All @@ -151,12 +148,12 @@ class HasBuilderSpec extends AnyFlatSpec with Matchers {
val x = 42
val y = "Peanuts"
val z = 'E'
builder set (X, x) set (Y, y) set (Z, z) build () should equal(expected)
builder set (X, x) set (Z, z) set (Y, y) build () should equal(expected)
builder set (Y, y) set (X, x) set (Z, z) build () should equal(expected)
builder set (Y, y) set (Z, z) set (X, x) build () should equal(expected)
builder set (Z, z) set (X, x) set (Y, y) build () should equal(expected)
builder set (Z, z) set (Y, y) set (X, x) build () should equal(expected)
builder.set(X, x).set(Y, y).set(Z, z).build() should equal(expected)
builder.set(X, x).set(Z, z).set(Y, y).build() should equal(expected)
builder.set(Y, y).set(X, x).set(Z, z).build() should equal(expected)
builder.set(Y, y).set(Z, z).set(X, x).build() should equal(expected)
builder.set(Z, z).set(X, x).set(Y, y).build() should equal(expected)
builder.set(Z, z).set(Y, y).set(X, x).build() should equal(expected)
}

// Test multiple optional parameters
Expand All @@ -182,45 +179,45 @@ class HasBuilderSpec extends AnyFlatSpec with Matchers {

// No arguments omitted
TestIntStringCharOptional(x, y, z) { expected =>
builder set (X, x) set (Y, y) set (Z, z) build () should equal(expected)
builder set (X, x) set (Z, z) set (Y, y) build () should equal(expected)
builder set (Y, y) set (X, x) set (Z, z) build () should equal(expected)
builder set (Y, y) set (Z, z) set (X, x) build () should equal(expected)
builder set (Z, z) set (X, x) set (Y, y) build () should equal(expected)
builder set (Z, z) set (Y, y) set (X, x) build () should equal(expected)
builder.set(X, x).set(Y, y).set(Z, z).build() should equal(expected)
builder.set(X, x).set(Z, z).set(Y, y).build() should equal(expected)
builder.set(Y, y).set(X, x).set(Z, z).build() should equal(expected)
builder.set(Y, y).set(Z, z).set(X, x).build() should equal(expected)
builder.set(Z, z).set(X, x).set(Y, y).build() should equal(expected)
builder.set(Z, z).set(Y, y).set(X, x).build() should equal(expected)
}

// x argument omitted
TestIntStringCharOptional(dx, y, z) { expected =>
builder set (Y, y) set (Z, z) build () should equal(expected)
builder set (Z, z) set (Y, y) build () should equal(expected)
builder.set(Y, y).set(Z, z).build() should equal(expected)
builder.set(Z, z).set(Y, y).build() should equal(expected)
}

// y argument omitted
TestIntStringCharOptional(x, dy, z) { expected =>
builder set (X, x) set (Z, z) build () should equal(expected)
builder set (Z, z) set (X, x) build () should equal(expected)
builder.set(X, x).set(Z, z).build() should equal(expected)
builder.set(Z, z).set(X, x).build() should equal(expected)
}

// z argument omitted
TestIntStringCharOptional(x, y, dz) { expected =>
builder set (X, x) set (Y, y) build () should equal(expected)
builder set (Y, y) set (X, x) build () should equal(expected)
builder.set(X, x).set(Y, y).build() should equal(expected)
builder.set(Y, y).set(X, x).build() should equal(expected)
}

// x and y omitted
TestIntStringCharOptional(dx, dy, z) { expected =>
builder set (Z, z) build () should equal(expected)
builder.set(Z, z).build() should equal(expected)
}

// x and z omitted
TestIntStringCharOptional(dx, y, dz) { expected =>
builder set (Y, y) build () should equal(expected)
builder.set(Y, y).build() should equal(expected)
}

// y and z omitted
TestIntStringCharOptional(x, dy, dz) { expected =>
builder set (X, x) build () should equal(expected)
builder.set(X, x).build() should equal(expected)
}

// All arguments omitted
Expand Down Expand Up @@ -256,27 +253,27 @@ class HasBuilderSpec extends AnyFlatSpec with Matchers {
val builder = TestEither.builder

TestEither(Left(42), None) should equal {
builder set(X, Left(42)) build()
builder.set(X, Left(42)).build()
}

TestEither(Right("Hello"), None) should equal {
builder set(X, Right("Hello")) build()
builder.set(X, Right("Hello")).build()
}

TestEither(Left(42), Some(Left(1000))) should equal {
builder set(Y, Some(Left(1000))) set(X, Left(42)) build()
builder.set(Y, Some(Left(1000))).set(X, Left(42)).build()
}

TestEither(Left(42), Some(Right("World"))) should equal {
builder set(Y, Some(Right("World"))) set(X, Left(42)) build()
builder.set(Y, Some(Right("World"))).set(X, Left(42)).build()
}

TestEither(Right("Hello"), Some(Left(1000))) should equal {
builder set(Y, Some(Left(1000))) set(X, Right("Hello")) build()
builder.set(Y, Some(Left(1000))).set(X, Right("Hello")).build()
}

TestEither(Right("Hello"), Some(Right("World"))) should equal {
builder set(Y, Some(Right("World"))) set(X, Right("Hello")) build()
builder.set(Y, Some(Right("World"))).set(X, Right("Hello")).build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@ object OrderOfScotch {
val order1 = OrderOfScotch.builder.set(Brand, "Takes").set(IsDouble, true).
set(Glass, Some(Tall)).set(Mode, OnTheRocks).build()

// Point-free version of the above
val order2 = (OrderOfScotch.builder
set (Brand, "Takes")
set (IsDouble, true)
set (Glass, Some(Tall))
set (Mode, OnTheRocks)
build ())

assert(order1 == OrderOfScotch("Takes", OnTheRocks, isDouble = true, Some(Tall)),
"Time to get out the scotch...")

assert(order1 == order2, "Traditional and point-free build results should be identical")
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.8
sbt.version=1.4.6