================================================================================
classes/constraints10
================================================================================

import "pkl:test"

const function matches(pattern: String): (String) -> Boolean = (str) -> str.matches(Regex(pattern))

class X {
  a: String(length >= 5, matches("\\w+\\.\\w+")) = "one.two"
}

res1 = new X {}

res2 = new X {
  a = "five.six"
}

res3 = test.catch(() ->
  new X {
    a = "n.o"
  }.a
)

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

(module
  (importClause
    (stringConstant))
  (classMethod
    (methodHeader
      (modifier)
      (identifier)
      (parameterList
        (typedIdentifier
          (identifier)
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier))))))
      (typeAnnotation
        (type
          (type
            (qualifiedIdentifier
              (identifier)))
          (type
            (qualifiedIdentifier
              (identifier))))))
    (functionLiteral
      (parameterList
        (typedIdentifier
          (identifier)))
      (methodCallExpr
        (variableExpr
          (identifier))
        (identifier)
        (argumentList
          (methodCallExpr
            (identifier)
            (argumentList
              (variableExpr
                (identifier))))))))
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (type
              (qualifiedIdentifier
                (identifier)))
            (binaryExpr
              (variableExpr
                (identifier))
              (intLiteral))
            (methodCallExpr
              (identifier)
              (argumentList
                (slStringLiteral
                  (escapeSequence)
                  (escapeSequence)
                  (escapeSequence))))))
        (slStringLiteral))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody)))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (slStringLiteral)))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (identifier)))))))
