programming-scala-book-code-examples icon indicating copy to clipboard operation
programming-scala-book-code-examples copied to clipboard

Getting errors trying to run examples

Open andrewdroz opened this issue 7 months ago • 7 comments

Hi there, I can't seem to easily start running the examples. After cloning, I ran sbt test but got:

Implicit parameters should be provided with a `using` clause.
assert(xs.min(om) == expected)

I resolved this - not sure if done the right way - by doing: assert(xs.min(using om) == expected)

But then I get other errors:

invariantEnabled(thing.label == "enabled")
Failed to evaluate macro.
Caused by java.lang.ClassNotFoundException: progscala3.meta.performance.invariantEnabled

As well as for class invariantMinInline

I am on openjdk 21.0.3 LTS and sbt 1.11.2

andrewdroz avatar Jun 15 '25 17:06 andrewdroz

Thanks for reporting this. A breaking change in Scala 3.7 apparently. I'll work on a fix today.

deanwampler avatar Jun 16 '25 14:06 deanwampler

I pushed fixes for the compiled code, so that sbt test should now work cleanly. There are still compilation bugs in the script examples, which I'll work on this evening.

deanwampler avatar Jun 16 '25 14:06 deanwampler

Thanks! sbt test is working now, although there are some failing tests. Are they to be expected? For example:

progscala3.forcomps.RemoveBlanksSuite:
==> X progscala3.forcomps.RemoveBlanksSuite.RemoveBlanks removes blank lines in text  0.034s munit.FailException: src\test\scala\progscala3\forcomps\RemoveBlanksSuite.scala:15
14:        |test   file""".stripMargin
15:    assert(actual == expected, s"""Actual:\n$actual\nExpected:\n$expected\n""")
16:  }
Actual:
  This is a       small
test   file
Expected:
  This is a       small
test   file

    at munit.FunSuite.assert(FunSuite.scala:13)
    at progscala3.forcomps.RemoveBlanksSuite.$init$$$anonfun$1(RemoveBlanksSuite.scala:15)
==> X progscala3.forcomps.RemoveBlanksSuite.RemoveBlanks optionally compresses whitespace in text  0.003s munit.FailException: src\test\scala\progscala3\forcomps\RemoveBlanksSuite.scala:24
23:        |test file""".stripMargin
24:    assert(actual == expected, s"""Actual:\n$actual\nExpected:\n$expected\n""")
25:  }
Actual:
This is a small
test file
Expected:
This is a small
test file

andrewdroz avatar Jun 16 '25 14:06 andrewdroz

Hmm. This passes for me. What OS are you using (e.g., MacOS, Windows, ...) and do you have a particular default language setting other than US English? For example, in my shell environment on MacOS, I have the environment variable definition: LANG=en_US.UTF-8.

deanwampler avatar Jun 16 '25 17:06 deanwampler

I finished going through the scripts (which aren't tested as thoroughly). All are working when they should and when they are supposed to throw errors, those cases are flagged.

deanwampler avatar Jun 17 '25 14:06 deanwampler

Hi Dean, the above failing tests were due to newlines in Windows OS. I've created a pull request that'll support Windows. I've also tested it on Mac OS and all tests are passing too.

andrewdroz avatar Jun 17 '25 15:06 andrewdroz

Thanks so much!! Merged.

Let me know if you have any remaining issues. If not, I'll close this. No rush...

deanwampler avatar Jun 17 '25 15:06 deanwampler

I'm going to close this, as it appears to be fixed...

deanwampler avatar Sep 20 '25 23:09 deanwampler