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

EOnumber$EOtimesTest fails #3793

Open
asmirnov-backend opened this issue Jan 8, 2025 · 5 comments
Open

EOnumber$EOtimesTest fails #3793

asmirnov-backend opened this issue Jan 8, 2025 · 5 comments

Comments

@asmirnov-backend
Copy link

asmirnov-backend commented Jan 8, 2025

EOnumber$EOtimesTest::throwsCorrectError fails with message

java.lang.AssertionError: the message in the error is correct
Expected: a string containing "number.times expects its second argument to be a number"
     but: was "Can't convert 1 bytes to java.lang.Double, exactly 8 bytes expected"
Expected :a string containing "number.times expects its second argument to be a number"
Actual   :"Can't convert 1 bytes to java.lang.Double, exactly 8 bytes expected"

Ref: #3461

@asmirnov-backend
Copy link
Author

asmirnov-backend commented Jan 8, 2025

If .otherwise("number.times expects its second argument to be a number") will be added to EOnumber$EOtimes::lambda, the test will pass, but the error message will be:

org.eolang.ExFailure: the 'x' attribute Can't convert 1 bytes to java.lang.Double, exactly 8 bytes expected number.times expects its second argument to be a number

This error message has problems with punctuation and a bit not clear, because Expect::otherwise concat 3 parts: String.format("%s %s %s", this.subject, ex.getMessage(), message)
@yegor256 can you please leave a comment about this

@asmirnov-backend
Copy link
Author

asmirnov-backend commented Jan 8, 2025

@yegor256 For EObytes$EOslice this code from test with small change for incorrect value

new Dataized(
    new PhWith(
        new PhWith(
            new Data.ToPhi("hello, world!")
                .take("as-bytes")
                .take("slice")
                .copy(),
            "start",
            new Data.ToPhi(2)
        ),
        "len",
        new Data.ToPhi(true) // incorrect value
    )
).take();

produces that error message

ERROR o.e.Dataized - Dataized to org.eolang.error with org.eolang.string inside, at:
  ⇢ 1) Error in "Φ.org.eolang.bytes.slice.Δ" at org.eolang.bytes:67:2
  ⇢ 2) "the 'len' attribute the 'len' attribute the 'len' attribute Can't convert 1 bytes to java.lang.Double, exactly 8 bytes expected must be a number must be an integer must be a positive integer"

Suppose that error message should be:
2) "the 'len' attribute must be a number"
or
2) "the 'len' attribute must be a number, must be an integer, must be a positive integer"?

@yegor256
Copy link
Member

yegor256 commented Jan 8, 2025

@asmirnov-backend indeed, this option is the excepted one:

"the 'len' attribute must be a number, must be an integer, must be a positive integer"

However, as I remember, the Expected class is supposed to be "fail fast": throw an exception at the first problem found.

@yegor256
Copy link
Member

yegor256 commented Jan 8, 2025

@asmirnov-backend there are some unit tests in the ExcpetTest file. I suggest first trying to add more tests there and reproduce desirable behavior. Then, fix bugs if they exist.

asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 8, 2025
asmirnov-backend added a commit to asmirnov-backend/eo that referenced this issue Jan 9, 2025
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

No branches or pull requests

2 participants