================================================================================
api/any
================================================================================

amends "../snippetTest.pkl"

examples {
  ["getClass()"] {
    1.getClass().simpleName
    1.2.getClass().simpleName
    true.getClass().simpleName
    "hello".getClass().simpleName
    5.min.getClass().simpleName
    5.mb.getClass().simpleName
    List(1, 2, 3).getClass().simpleName
    Map("one", 1, "two", 2).getClass().simpleName
    new Listing { 1; 2; 3 }.getClass().simpleName
    new Mapping { ["one"] = 1; ["two"] = 2 }.getClass().simpleName
    new Dynamic { x = 1; y = 2 }.getClass().simpleName
    new Person { name = "Pigeon" }.getClass().simpleName
    Person.getClass().simpleName
    null.getClass().simpleName
    Pair(1, 2).getClass().simpleName
    import("pkl:base").getClass().simpleName
  }

  ["ifNonNull"] {
    local s = 10

    s.ifNonNull((x) -> x)
    s.ifNonNull((x) -> "foo")
    s.ifNonNull((x) -> null)

    null.ifNonNull((x) -> x)
    null.ifNonNull((x) -> "foo")
    null.ifNonNull((x) -> null)
  }

  ["toString()"] {
    "Pigeon".toString()
    42.toString()
    1.23.toString()
    true.toString()
    1.23.ns.toString()
    1.23.mb.toString()
    Pair(1, 2).toString()
    List(1, 2, 3).toString()
    Set(1, 2, 3).toString()
    Map(1, 2, 3, 4).toString()
    new Listing { 1 2 3 }.toString()
    new Mapping { ["Pigeon"] = 42; ["Barn Owl"] = 21 }.toString()
    new Dynamic { name = "Pigeon"; age = 42 }.toString()
    new Person2 { name = "Pigeon"; age = 42 }.toString()
    null.toString()
    Null(new Dynamic { name = "Pigeon" }).toString()
  }
}

local class Person {
  name: String
}

local class Person2 {
  name: String
  age: Int
}

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

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