From b4882289d871af116465036b4141dbf14697a60f Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:32:56 +0200 Subject: [PATCH] WIP: Add tests, which obviously fail ^^ Todo: We need to have a concept for generating temporal variable ids without nameclash The transpilation is inspired how EEL does it: https://github.com/neos/flow-development-collection/blob/70bc49cc946c443dadfe26c49a19d710ece4ad48/Neos.Eel/Classes/CompilingEelParser.php#L163-L180 simplified the eel transpilation of or would look like: `($leftExpressionResult = $leftExpression) ? $leftExpressionResult : $rightExpression` --- .../BinaryOperation/BinaryOperationTranspilerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Unit/Target/Php/Transpiler/BinaryOperation/BinaryOperationTranspilerTest.php b/test/Unit/Target/Php/Transpiler/BinaryOperation/BinaryOperationTranspilerTest.php index d4b5112a..f4bb374e 100644 --- a/test/Unit/Target/Php/Transpiler/BinaryOperation/BinaryOperationTranspilerTest.php +++ b/test/Unit/Target/Php/Transpiler/BinaryOperation/BinaryOperationTranspilerTest.php @@ -36,6 +36,11 @@ final class BinaryOperationTranspilerTest extends TestCase public function binaryOperationExamples(): array { return [ + // in php the or operator is not 100% equivalent to ecmascript + // `null || "fallback"` will be `true` in php but we want "fallback" like in js + 'null || "fallback"' => '($temp_123 = null) ? $temp_123 : "fallback"', + 'null && "fallback"' => '($temp_123 = null) ? "fallback" : $temp_123', + 'true && false' => ['true && false', '(true && false)'], 'a && false' => ['a && false', '($this->a && false)'], 'true && b' => ['true && b', '(true && $this->b)'],