-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add spec conformance tests for Floating-point-literal #947
Conversation
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
There are failing test cases against the test runner. |
The Team is busy with finalizing the SwanLake GA release. Hence closing this PR temporarily. |
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
Let's add test cases for HexFloatingPointLiteral, that are combined(appended to hex value) with |
There should have test cases for,
|
Do we have test cases for this |
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
} | ||
|
||
Test-Case: output | ||
Description: Test HexFloatingPointLiteral with toString(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason to add toString tests specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was added when when we first wrote the tests to see if the output was correct, like if it has the correct number of zero digits after the decimal point and so on.
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
conformance/lang/expressions/literals/floating_point_literal.balt
Outdated
Show resolved
Hide resolved
@KavinduZoysa regarding :
those tests are already there in: |
g = 56763457; | ||
io:println(g); // @output 56763457 | ||
|
||
g = 0d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not split these tests similar to float above?
Description: Test out of range decimal floating point literal with decimal type descriptor. | ||
Labels: decimal | ||
|
||
function init() { | ||
decimal a = 9.99E+6111; | ||
io:println(a); // @output 9.99E+6111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this output correct if out of range? cc @KavinduZoysa
|
||
} | ||
|
||
function printDecimalFloatingPoint1() returns float|decimal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to change here, but taking this as an example for future tests, we can make tests simpler by avoiding testing the same thing over and over again.
We've already tested different literals against float|decimal, so we don't have to test in every context. Just one or two would be enough.
} | ||
|
||
Test-Case: output | ||
Description: Test the basic type when the applicable contextually expected type is a subtype of float, having a union with nil and float types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to keep, but why were these tests added? What exactly was the special scenario we wanted to test?
io:println(x is float); | ||
io:println(x is int); | ||
io:println(x is decimal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not in order int, float, decimal? Or at least float, decimal, int.
Description: Test rounding floating point values with float type. | ||
Labels: float, FloatingPointTypeSuffix, HexFloatingPointLiteral | ||
|
||
function init() { | ||
float c = float:round(0.001234, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these tests added? These are float (and decimal) langlib tests.
} | ||
|
||
Test-Case: error | ||
Description: Test hex indicator with float type descriptor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't properly describe the test?
Labels: decimal, HexFloatingPointLiteral | ||
|
||
function errorFunction() { | ||
decimal _ = 0x1.0fp+10; // @error hex floating point literal is incompatible with 'decimal' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incompatible -> not allowed
function init() { | ||
float|decimal a = 0x1.0; | ||
|
||
if (a is decimal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (a is decimal) { | |
if a is decimal { |
} | ||
|
||
Test-Case: output | ||
Description: Test hex floating point literal type narrowing with floating point type descriptor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type narrowing is on the variable, not the literal. Can we update this to say narrowing when a literal is used with the union of float and decimal instead?
Purpose
$title
Related lang issue #32474