def test_nested_non_grouped_ternary_expression(): assert DefaultParser().parse( 'foo ? bar ? 1 : 2 : 3') == ConditionalExpression( test=Identifier('foo'), consequent=ConditionalExpression(test=Identifier('bar'), consequent=Literal(1), alternate=Literal(2)), alternate=Literal(3))
def test_object_ternary_expression(): assert DefaultParser().parse( 'foo ? {bar: "tek"} : "baz"') == ConditionalExpression( test=Identifier('foo'), consequent=ObjectLiteral({'bar': Literal('tek')}), alternate=Literal('baz'))
def test_ternary_expression(): assert DefaultParser().parse('foo ? 1 : 0') == ConditionalExpression( test=Identifier('foo'), consequent=Literal(1), alternate=Literal(0))