Skip to content

Commit

Permalink
Last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Dec 22, 2017
1 parent ea4895e commit 7ec76bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class WollokLauncherParameters {
val parser = new OptionalGnuParser
val cmdLine = parser.parse(options, args, false)

args.forEach[ println(it) ]

hasRepl = cmdLine.hasOption("r")

tests = cmdLine.hasOption("t")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ abstract class NumberCoercingStrategy {
def BigDecimal adaptResult(BigDecimal value) { value }
def String description()
def String name()
def void warnIfScaleDoesNotMatch(BigDecimal value, BigDecimal result) {
if (value.scale > WollokNumbersPreferences.instance.decimalPositions) {
println(NLS.bind(Messages.WollokConversion_WARNING_NUMBER_VALUE_INTEGER, value, result))
}
}
}

class TruncateDecimalsCoercingStrategy extends NumberCoercingStrategy {
Expand All @@ -27,11 +32,9 @@ class TruncateDecimalsCoercingStrategy extends NumberCoercingStrategy {
result
}

override adaptValue(BigDecimal value) {
override adaptValue(BigDecimal value) {
val result = value.setScale(WollokNumbersPreferences.instance.decimalPositions, RoundingMode.DOWN)
if (value.scale > WollokNumbersPreferences.instance.decimalPositions) {
println(NLS.bind(Messages.WollokConversion_WARNING_NUMBER_VALUE_INTEGER, value, result))
}
value.warnIfScaleDoesNotMatch(result)
result
}

Expand Down Expand Up @@ -81,7 +84,11 @@ class RoundingDecimalsCoercingStrategy extends NumberCoercingStrategy {
override coerceToInteger(BigDecimal value) {
value.intValue
}
override adaptValue(BigDecimal value) { value.setScale(WollokNumbersPreferences.instance.decimalPositions, RoundingMode.HALF_UP) }
override adaptValue(BigDecimal value) {
val result = value.setScale(WollokNumbersPreferences.instance.decimalPositions, RoundingMode.HALF_UP)
value.warnIfScaleDoesNotMatch(result)
result
}

override name(){
"decimals"
Expand Down

0 comments on commit 7ec76bd

Please sign in to comment.