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

CATROID-1364 List show 1/0 instead of true/false #5062

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.catrobat.catroid.formulaeditor.FormulaElement.ElementType.OPERATOR
import org.catrobat.catroid.formulaeditor.FormulaElement.ElementType.FUNCTION
import org.catrobat.catroid.formulaeditor.Functions.FALSE
import org.catrobat.catroid.formulaeditor.Functions.TRUE
import org.catrobat.catroid.formulaeditor.common.Conversions

class AssertEqualsAction : AssertAction() {
var actualFormula: Formula? = null
Expand All @@ -48,6 +49,12 @@ class AssertEqualsAction : AssertAction() {

actualValue = actualFormula!!.interpretObject(scope)
expectedValue = expectedFormula!!.interpretObject(scope)
if (actualValue == true || actualValue == false){
actualValue = Conversions.booleanToDouble(actualValue as Boolean)
}
if (expectedValue == true || expectedValue == false){
expectedValue = Conversions.booleanToDouble(expectedValue as Boolean)
}
if (!equalValues(actualValue.toString(), expectedValue.toString())) {
convertValuesToBooleanString()
failWith(formattedAssertEqualsError(actualValue, expectedValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ object FormulaElementOperations {
} catch (_: NumberFormatException) {
Double.NaN
}
is Boolean -> if(obj) 1.0 else 0.0
else -> obj as Double
}
}
Expand All @@ -92,7 +93,7 @@ object FormulaElementOperations {
return when (value) {
is String,
is Char -> value
is Boolean -> Conversions.booleanToDouble(value)
is Boolean -> value
is Int -> value.toDouble()
is Double -> when (value) {
Double.NEGATIVE_INFINITY -> -Double.MAX_VALUE
Expand Down