================================================================================
basic/boolean
================================================================================

amends "../snippetTest.pkl"

local x = true
local y = false

examples {
  ["literal"] {
    true
    false
  }

  ["conjunction"] {
    x && y
    false && "short-circuited"
    false && throw("short-circuited")

    module.catch(() -> true && throw("not short-circuited"))
    module.catch(() -> (throw("not short-circuited")) && false)
    module.catch(() -> 1 && true)
  }

  ["disjunction"] {
    x || y
    true || "short-circuited"
    true || throw("short-circuited")

    module.catch(() -> false || throw("not short-circuited"))
    module.catch(() -> (throw("not short-circuited")) || true)
    module.catch(() -> 0 || true)
  }

  ["negation"] {
    !x
    !y
  }

  ["equality"] {
    true == true
    true == false
    false == true
    false == false
  }

  ["inequality"] {
    true != true
    true != false
    false != true
    false != false
  }

  ["xor()"] {
    true.xor(true)
    true.xor(false)
    false.xor(true)
    false.xor(false)

    List().isEmpty.xor(List().isEmpty)
    List().isEmpty.xor(List(1).isEmpty)
    List(1).isEmpty.xor(List().isEmpty)
    List(1).isEmpty.xor(List(1).isEmpty)

    module.catch(() -> new Dynamic {}.xor(true))
    module.catch(() -> true.xor(new Dynamic {}))
  }

  ["implies()"] {
    true.implies(true)
    true.implies(false)
    false.implies(true)
    false.implies(false)
    module.catch(() -> false.implies(throw("not short-circuited")))
  }
}

--------------------------------------------------------------------------------

(module
  (moduleHeader
    (extendsOrAmendsClause
      (stringConstant)))
  (classProperty
    (modifier)
    (identifier)
    (trueLiteral))
  (classProperty
    (modifier)
    (identifier)
    (falseLiteral))
  (classProperty
    (identifier)
    (objectBody
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (trueLiteral))
          (objectElement
            (falseLiteral))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (binaryExpr
              (variableExpr
                (identifier))
              (variableExpr
                (identifier))))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (slStringLiteral)))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (throwExpr
                (parenthesizedExpr
                  (slStringLiteral)))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (trueLiteral)
                    (throwExpr
                      (parenthesizedExpr
                        (slStringLiteral))))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (parenthesizedExpr
                      (throwExpr
                        (parenthesizedExpr
                          (slStringLiteral))))
                    (falseLiteral))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (intLiteral)
                    (trueLiteral))))))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (binaryExpr
              (variableExpr
                (identifier))
              (variableExpr
                (identifier))))
          (objectElement
            (binaryExpr
              (trueLiteral)
              (slStringLiteral)))
          (objectElement
            (binaryExpr
              (trueLiteral)
              (throwExpr
                (parenthesizedExpr
                  (slStringLiteral)))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (falseLiteral)
                    (throwExpr
                      (parenthesizedExpr
                        (slStringLiteral))))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (parenthesizedExpr
                      (throwExpr
                        (parenthesizedExpr
                          (slStringLiteral))))
                    (trueLiteral))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (binaryExpr
                    (intLiteral)
                    (trueLiteral))))))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (unaryExpr
              (variableExpr
                (identifier))))
          (objectElement
            (unaryExpr
              (variableExpr
                (identifier))))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (binaryExpr
              (trueLiteral)
              (trueLiteral)))
          (objectElement
            (binaryExpr
              (trueLiteral)
              (falseLiteral)))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (trueLiteral)))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (falseLiteral)))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (binaryExpr
              (trueLiteral)
              (trueLiteral)))
          (objectElement
            (binaryExpr
              (trueLiteral)
              (falseLiteral)))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (trueLiteral)))
          (objectElement
            (binaryExpr
              (falseLiteral)
              (falseLiteral)))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (methodCallExpr
              (trueLiteral)
              (identifier)
              (argumentList
                (trueLiteral))))
          (objectElement
            (methodCallExpr
              (trueLiteral)
              (identifier)
              (argumentList
                (falseLiteral))))
          (objectElement
            (methodCallExpr
              (falseLiteral)
              (identifier)
              (argumentList
                (trueLiteral))))
          (objectElement
            (methodCallExpr
              (falseLiteral)
              (identifier)
              (argumentList
                (falseLiteral))))
          (objectElement
            (methodCallExpr
              (propertyCallExpr
                (methodCallExpr
                  (identifier)
                  (argumentList))
                (identifier))
              (identifier)
              (argumentList
                (propertyCallExpr
                  (methodCallExpr
                    (identifier)
                    (argumentList))
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (propertyCallExpr
                (methodCallExpr
                  (identifier)
                  (argumentList))
                (identifier))
              (identifier)
              (argumentList
                (propertyCallExpr
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (intLiteral)))
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (propertyCallExpr
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (intLiteral)))
                (identifier))
              (identifier)
              (argumentList
                (propertyCallExpr
                  (methodCallExpr
                    (identifier)
                    (argumentList))
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (propertyCallExpr
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (intLiteral)))
                (identifier))
              (identifier)
              (argumentList
                (propertyCallExpr
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (intLiteral)))
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (methodCallExpr
                    (newExpr
                      (type
                        (qualifiedIdentifier
                          (identifier)))
                      (objectBody))
                    (identifier)
                    (argumentList
                      (trueLiteral)))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (methodCallExpr
                    (trueLiteral)
                    (identifier)
                    (argumentList
                      (newExpr
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (objectBody))))))))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (methodCallExpr
              (trueLiteral)
              (identifier)
              (argumentList
                (trueLiteral))))
          (objectElement
            (methodCallExpr
              (trueLiteral)
              (identifier)
              (argumentList
                (falseLiteral))))
          (objectElement
            (methodCallExpr
              (falseLiteral)
              (identifier)
              (argumentList
                (trueLiteral))))
          (objectElement
            (methodCallExpr
              (falseLiteral)
              (identifier)
              (argumentList
                (falseLiteral))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (methodCallExpr
                    (falseLiteral)
                    (identifier)
                    (argumentList
                      (throwExpr
                        (parenthesizedExpr
                          (slStringLiteral))))))))))))))
