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

Regression since 1.4.1 - result of calculation involving java Long is converted to Double #2600

Closed
bouncysteve opened this issue Aug 16, 2024 · 6 comments

Comments

@bouncysteve
Copy link

All of the following passed in 1.4.1. Only the first two pass in 1.5.0:

@math
Scenario: convert result of adding two ints to string
    * string result = 3 + 1
    # passes
    * match result == '4'
@math
Scenario: convert java Long to string
    * string result = new java.lang.Long(4)
    # passes
    * match result == '4'
@math
Scenario: convert result of adding int to java long to string
    * string result = new java.lang.Long(3) + 1
    # fails - converts to '4.0'
    * match result == '4'
@math
Scenario: convert result of adding java long to int to string
    * string result = 3 + new java.lang.Long(1)
    # fails - converts to '4.0'
    * match result == '4'
@math
Scenario: convert result of adding two java longs to string
    * string result = new java.lang.Long(3) + new java.lang.Long(1)
    # fails - converts to '4.0'
    * match result == '4'
@ptrthomas
Copy link
Member

I'm not sure how to deal with this to be honest, and I don't think using java.lang.Long etc. is common and certainly has never been encouraged. I'll leave this open and see if any others report this

@bouncysteve
Copy link
Author

bouncysteve commented Aug 16, 2024 via email

@ptrthomas
Copy link
Member

@bouncysteve the change is most likely the JS engine upgrade here: #2536 - which is why this is a hard problem to fix

JS engine changes have been so troublesome that we decided to write our own as a plan B, FYI: https://github.com/karatelabs/karate-js

just curious - why do you need to do this manipulation in the first place, can't you just use parseInt() instead of the java Long ?

@bouncysteve
Copy link
Author

bouncysteve commented Aug 19, 2024 via email

@ptrthomas
Copy link
Member

@bouncysteve good to know, thanks. I'll keep this open for a while anyway - to see if others have similar issues

@ptrthomas
Copy link
Member

closing as no others have reported this

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

No branches or pull requests

2 participants