Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
fix: Condition operation default case return false
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Tes Carrasque <daniel@zup.com.br>
  • Loading branch information
dantes-git committed Apr 5, 2022
1 parent 8039d8d commit 91e22b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ final class OperationLogicEvaluationTests: OperationEvaluationTests {

let simpleOperations = ["true, 1, 0", "false, 'yes', 'no'", "\(binding), true, false"].toOperations(name: name)

let complexOperations = ["\(simpleOperations[2].rawValue), 1.1, 0.0"].toOperations(name: name)
let complexOperations = ["\(simpleOperations[2].rawValue), 1.1, 0.0", "null, 1, 0", "true, 1, 0.0"].toOperations(name: name)

let failingOperations = ["1, 0", "1, 1, 0", "true, 1, 0.0", ""].toOperations(name: name)
let failingOperations = ["1, 0", ""].toOperations(name: name)

let operations = simpleOperations + complexOperations + failingOperations

let comparableResults: [DynamicObject] = [1, "no", true, 1.1, nil, nil, nil, nil]
let comparableResults: [DynamicObject] = [1, "no", true, 1.1, 0, 1, nil, nil]

// When
evaluateOperations(operations, contexts: contexts) { evaluatedResults in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ extension OperationsProvider {
return { parameters in
guard parameters.count == 3 else { return nil }

guard case let .bool(firstParameter) = parameters[0],
parameters[1].isEqualIgnoringAssociatedValues(parameters[2]) else { return nil }

return firstParameter ? parameters[1] : parameters[2]
if case let .bool(firstParameter) = parameters[0], firstParameter {
return parameters[1]
}
return parameters[2]
}
}

Expand Down

0 comments on commit 91e22b2

Please sign in to comment.