================================================================================
api/pcfRenderer4
================================================================================

import "pkl:test"

class Person {
  name: String
  age: Int
}

typealias Email = String

local renderer = new PcfRenderer {}

res1 = renderer.renderValue(123)
res2 = renderer.renderValue(1.23)
res3 = renderer.renderValue(false)
res4 = renderer.renderValue("pigeon")
res5 = renderer.renderValue(List("pigeon", "parrot"))
res6 = renderer.renderValue(Set("pigeon", "parrot"))
res7 = renderer.renderValue(Map("name", "pigeon", "age", 42))
res8 = renderer.renderValue(new Listing { "pigeon"; "parrot" })
res9 = renderer.renderValue(new Mapping { ["name"] = "pigeon"; ["age"] = 42 })
res10 = renderer.renderValue(new Dynamic { name = "pigeon"; age = 42 })
res11 = renderer.renderValue(new Person { name = "pigeon"; age = 42 })
res12 = renderer.renderValue(1.min)
res13 = renderer.renderValue(1.mb)
res14 = renderer.renderValue(null)
res15 = renderer.renderValue(Pair(1, 2))
res16 = renderer.renderValue(IntSeq(1, 4))
res17 = renderer.renderValue(IntSeq(1, 4).step(-2))
res18 = renderer.renderValue(Regex("a.*b"))

res19 = test.catch(() -> renderer.renderValue(Person))
res20 = test.catch(() -> renderer.renderValue(Email))
res21 = test.catch(() -> renderer.renderValue((x) -> x))
res22 = test.catch(() -> new PcfRenderer { converters { [Int] = (_) -> throw("ouch") } }.renderValue(42))

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

(module
  (importClause
    (stringConstant))
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier)))))
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier)))))))
  (typeAlias
    (identifier)
    (type
      (qualifiedIdentifier
        (identifier))))
  (classProperty
    (modifier)
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (floatLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (falseLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (slStringLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral)
            (slStringLiteral)
            (intLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectElement
              (slStringLiteral))
            (objectElement
              (slStringLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectEntry
              (slStringLiteral)
              (slStringLiteral))
            (objectEntry
              (slStringLiteral)
              (intLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))
            (objectProperty
              (identifier)
              (intLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (newExpr
          (type
            (qualifiedIdentifier
              (identifier)))
          (objectBody
            (objectProperty
              (identifier)
              (slStringLiteral))
            (objectProperty
              (identifier)
              (intLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (propertyCallExpr
          (intLiteral)
          (identifier)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (propertyCallExpr
          (intLiteral)
          (identifier)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (nullLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (intLiteral)
            (intLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (intLiteral)
            (intLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (methodCallExpr
            (identifier)
            (argumentList
              (intLiteral)
              (intLiteral)))
          (identifier)
          (argumentList
            (unaryExpr
              (intLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (variableExpr
                (identifier))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (variableExpr
                (identifier))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (variableExpr
              (identifier))
            (identifier)
            (argumentList
              (functionLiteral
                (parameterList
                  (typedIdentifier
                    (identifier)))
                (variableExpr
                  (identifier)))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (objectBody
                    (objectEntry
                      (variableExpr
                        (identifier))
                      (functionLiteral
                        (parameterList
                          (typedIdentifier
                            (identifier)))
                        (throwExpr
                          (parenthesizedExpr
                            (slStringLiteral)))))))))
            (identifier)
            (argumentList
              (intLiteral))))))))
