Skip to content
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

A series of compilation/test errors in the math algorithms #41

Closed
Vopaaz opened this issue Jan 12, 2020 · 3 comments · Fixed by #66
Closed

A series of compilation/test errors in the math algorithms #41

Vopaaz opened this issue Jan 12, 2020 · 3 comments · Fixed by #66

Comments

@Vopaaz
Copy link

Vopaaz commented Jan 12, 2020

Error 1

The function abs seems to be not in the global namespace.

[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMax.scala:11:42: not found: value abs
[error]         def absMax(elements : List[Int]): Int = abs(elements.maxBy(x => abs(x)))
[error]                                                 ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMax.scala:11:66: not found: value abs
[error]         def absMax(elements : List[Int]): Int = abs(elements.maxBy(x => abs(x)))
[error]                                                                         ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMax.scala:11:60: diverging implicit expansion for type Ordering[B]
[error] starting with method Tuple9 in object Ordering
[error]         def absMax(elements : List[Int]): Int = abs(elements.maxBy(x => abs(x)))
[error]                                                                   ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMin.scala:11:42: not found: value abs
[error]         def absMin(elements : List[Int]): Int = abs(elements.minBy(x => abs(x)))
[error]                                                 ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMin.scala:11:66: not found: value abs
[error]         def absMin(elements : List[Int]): Int = abs(elements.minBy(x => abs(x)))
[error]                                                                         ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\main\scala\Mathematics\AbsMin.scala:11:60: diverging implicit expansion for type Ordering[B]
[error] starting with method Tuple9 in object Ordering
[error]         def absMin(elements : List[Int]): Int = abs(elements.minBy(x => abs(x)))
[error]                                                                   ^
[error] 6 errors found
[error] (compile:compileIncremental) Compilation failed

This can be fixed by adding import scala.math._, or if you want to use your implementation of abs, use Abs.abs will also work.

Error 2

A right parenthesis is missing in a test case.

[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Array\MaximumAbsoluteDifferenceSpec.scala:9:3: ')' expected but '}' found.
[error]   }
[error]   ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 4 s, completed 2020-1-12 22:23:58

This can be fixed by changing assert(MaximumAbsoluteDifferenceSpec.maxAbsDiff(Array(1, 3, -1) === 5) to assert(MaximumAbsoluteDifferenceSpec.maxAbsDiff(Array(1, 3, -1)) === 5) in

assert(MaximumAbsoluteDifferenceSpec.maxAbsDiff(Array(1, 3, -1) === 5)

Error 3

(folding other similar errors)

[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Sort\SelectionSortSpec.scala:9:49: package Array is not a value
[error]     assert(SelectionSort.selectionSort(arr) === Array(0,1,2,3,7,9))
[error]                                                 ^
[error] 32 errors found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed 2020-1-12 22:29:51

The problem, package Array is not a value, seems to happen because the package name conflicts with the Array scala type, therefore can be fixed with changing package Array to package ArrayTest.

Error 4

[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Array\MaximumAbsoluteDifferenceSpec.scala:8:12: not found: value MaximumAbsoluteDifferenceSpec
[error]     assert(MaximumAbsoluteDifferenceSpec.maxAbsDiff(Array(1, 3, -1)) === 5)
[error]            ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Array\MaximumAbsoluteDifferenceSpec.scala:12:12: not found: value MaximumAbsoluteDifferenceSpec
[error]     assert(MaximumAbsoluteDifferenceSpec.maxAbsDiff(Array(4, 3, 0, 9, -1, 6, -5)) === 17)

I do not know where does the maxAbsDiff comes from. There is not even a method definition. All I can do is to delete that file.

Error 5

[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\AbsMaxSpec.scala:8:33: 6 more arguments than can be applied to method absMax: (elements: List[Int])Int
[error]     assert(AbsMax.absMax(-1000, -1, 999, 72, 65, -56, -767) === 1000)
[error]                                 ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\AbsMaxSpec.scala:12:31: 3 more arguments than can be applied to method absMax: (elements: List[Int])Int
[error]     assert(AbsMax.absMax(121, 221, 3, 4112) === 4112)
[error]                               ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\AbsMinSpec.scala:8:32: 6 more arguments than can be applied to method absMin: (elements: List[Int])Int
[error]     assert(AbsMin.absMin(1000, -1, 999, 72, 65, -56, -767) === 1)
[error]                                ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\AbsMinSpec.scala:12:31: 3 more arguments than can be applied to method absMin: (elements: List[Int])Int
[error]     assert(AbsMin.absMin(121, 221, 3, 4112) === 3)
[error]                               ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\FindMaxSpec.scala:8:35: 6 more arguments than can be applied to method findMax: (elements: List[Int])Int
[error]     assert(FindMax.findMax(-1000, -1, 999, 72, 65, -56, -767) === 999)
[error]                                   ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\FindMaxSpec.scala:12:33: 3 more arguments than can be applied to method findMax: (elements: List[Int])Int
[error]     assert(FindMax.findMax(121, 221, 3, 4112) === 4112)
[error]                                 ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\FindMinSpec.scala:8:35: 6 more arguments than can be applied to method findMin: (elements: List[Int])Int
[error]     assert(FindMin.findMin(-1000, -1, 999, 72, 65, -56, -767) === -1000)
[error]                                   ^
[error] C:\Personal\gitkrakenRepo\Scala-Algorithms\src\test\scala\Mathematics\FindMinSpec.scala:12:33: 3 more arguments than can be applied to method findMin: (elements: List[Int])Int
[error]     assert(FindMin.findMin(121, 221, 3, 4112) === 3)

These failures suggest type mismatch from a List to a series of Numbers, which can be fixed via changing, for example, assert(AbsMax.absMax(-1000, -1, 999, 72, 65, -56, -767) === 1000) to assert(AbsMax.absMax(List(-1000, -1, 999, 72, 65, -56, -767)) === 1000).

Error 6

[info] Mathematics.AbsMaxSpec *** ABORTED ***
[info]   Duplicate test name: should output the correct Integer as a result from the list of elements (AbsMaxSpec.scala:11)
[info] AbsMinSpec:
[info] FindMaxSpec:
[info] FindMinSpec:
[info] AbsSpec:
[info] Run completed in 896 milliseconds.
[info] Total number of tests run: 30
[info] Suites: completed 17, aborted 6
[info] Tests: succeeded 30, failed 0, canceled 0, ignored 0, pending 0
[info] *** 6 SUITES ABORTED ***
[error] Error during tests:
[error]         Mathematics.AbsMaxSpec
[error]         Mathematics.AbsMinSpec
[error]         Mathematics.FindMinSpec
[error]         Mathematics.GreaterCommonDivisorSpec
[error]         Mathematics.FindMaxSpec
[error]         Mathematics.AbsSpec
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 4 s, completed 2020-1-12 22:42:05

Lots of test suites failed. Because their description is duplicated (Duplicate test name). It can be fixed by changing the test names.


Am I missing something in the environment setup? Or is the project just unmaintained and the CI is not running? The second error, missing right parenthesis, does not look like anything that could possibly originate from my flawed environment setup but rather a human error, which should be detected by the CI.

@criskolonas
Copy link

the project is unmaintained unfortunately

@rezzzza
Copy link

rezzzza commented May 24, 2020

the project is unmaintained unfortunately

No, It seems to be maintained

@nvkhuy
Copy link
Contributor

nvkhuy commented Jul 31, 2020

Errors had been fixed in #51 and #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants