-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mixed Decimal/Float operations throw error or attach warning (#10725)
- Loading branch information
1 parent
4d2cc04
commit e836373
Showing
9 changed files
with
444 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
262 changes: 213 additions & 49 deletions
262
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Decimal.enso
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/Base_Internal_Tests/src/Decimal_Constructor_Spec.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from Standard.Base import all | ||
|
||
from Standard.Test import all | ||
|
||
id_decimal (x : Decimal) -> Decimal = x | ||
|
||
is_value_constructor d = case d of | ||
Decimal.Value _ -> True | ||
Decimal.From_Float _ _ -> False | ||
|
||
add_specs suite_builder = | ||
suite_builder.group "(Decimal_Constructor_Spec) conversions" group_builder-> | ||
group_builder.specify "Conversion from float to decimal should use the correct constructor" <| | ||
is_value_constructor (dec 0.1) . should_be_true | ||
is_value_constructor (0.1 . to_decimal) . should_be_true | ||
is_value_constructor (0.1 . to_decimal) . should_be_true | ||
is_value_constructor (Decimal.from_float 0.1) . should_be_true | ||
|
||
is_value_constructor (Decimal.new 0.1) . should_be_false | ||
is_value_constructor (Decimal.from 0.1) . should_be_false | ||
is_value_constructor (Decimal.from_float 0.1 explicit=False) . should_be_false | ||
is_value_constructor (id_decimal 0.1) . should_be_false | ||
|
||
main filter=Nothing = | ||
suite = Test.build suite_builder-> | ||
add_specs suite_builder | ||
suite.run_with_filter filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.