================================================================================
basic/nonNull
================================================================================

amends "../snippetTest.pkl"

local class Person { name: String = "Pigeon" }

facts {
  ["returns its non-null operand"] {
    123!! == 123
    let (x = 123) x!! == 123
    1.23.ms!! == 1.23.ms
    Pair(21, 42)!! == Pair(21, 42)
    new Person {}!! == new Person {}
  }
}

examples {
  ["fails if operand is null"] {
    module.catch(() -> null!!)
    module.catch(() -> let (x = null) x!!)
  }
}

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

(module
  (moduleHeader
    (extendsOrAmendsClause
      (stringConstant)))
  (clazz
    (modifier)
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))))
        (slStringLiteral))))
  (classProperty
    (identifier)
    (objectBody
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (binaryExpr
              (unaryExpr
                (intLiteral))
              (intLiteral)))
          (objectElement
            (letExpr
              (typedIdentifier
                (identifier))
              (intLiteral)
              (binaryExpr
                (unaryExpr
                  (variableExpr
                    (identifier)))
                (intLiteral))))
          (objectElement
            (propertyCallExpr
              (binaryExpr
                (unaryExpr
                  (propertyCallExpr
                    (floatLiteral)
                    (identifier)))
                (floatLiteral))
              (identifier)))
          (objectElement
            (binaryExpr
              (unaryExpr
                (methodCallExpr
                  (identifier)
                  (argumentList
                    (intLiteral)
                    (intLiteral))))
              (methodCallExpr
                (identifier)
                (argumentList
                  (intLiteral)
                  (intLiteral)))))
          (objectElement
            (binaryExpr
              (unaryExpr
                (newExpr
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (objectBody)))
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody))))))))
  (classProperty
    (identifier)
    (objectBody
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (unaryExpr
                    (nullLiteral))))))
          (objectElement
            (methodCallExpr
              (moduleExpr)
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (letExpr
                    (typedIdentifier
                      (identifier))
                    (nullLiteral)
                    (unaryExpr
                      (variableExpr
                        (identifier)))))))))))))
