================================================================================
classes/mapConstraints1
================================================================================

import "pkl:test"

class Numbers {
  xs: Map<String, Int>
  ys: Map<String(!isEmpty), Int(this < 0)>
  zs: Map<String(!isEmpty), Int(this < 0)>(length >= 5)
}

class Numbers2 {
  // type constraint but no type parameters
  ys: Map(every((key, value) -> key is String(!isEmpty) && value is Int(this < 0)))
}

res1 = new Numbers {
  xs = Map("one", 1, "two", 2, "three", 3)
  ys = Map("-one", -1, "-two", -2, "-three", -3)
  zs = Map("-one", -1, "-two", -2, "-three", -3, "-four", -4, "-five", -5)
}

res1b = new Numbers2 {
  ys = Map("-one", -1, "-two", -2, "-three", -3)
}

res2 = test.catch(() ->
  new Numbers {
    xs = "numbers"
  }.xs
)

res3 = test.catch(() ->
  new Numbers {
    xs = Map("one", "one")
  }.xs
)

res4 = test.catch(() ->
  new Numbers {
    xs = Map(1, 1)
  }.xs
)

res5 = test.catch(() ->
  new Numbers {
    ys = Map("one", 1, "two", 2, "three", 3)
  }.ys
)

res5b = test.catch(() ->
  new Numbers2 {
    ys = Map("one", 1, "two", 2, "three", 3)
  }.ys
)

res6 = test.catch(() ->
  new Numbers {
    ys = Map("", -1, "-two", -2, "-three", -3)
  }.ys
)

res6b = test.catch(() ->
  new Numbers2 {
    ys = Map("", -1, "-two", -2, "-three", -3)
  }.ys
)

res7 = test.catch(() ->
  new Numbers {
    zs = Map("-one", -1, "-two", -2, "-three", -3)
  }.zs
)

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

(module
  (importClause
    (stringConstant))
  (clazz
    (identifier)
    (classBody
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier)))
              (type
                (qualifiedIdentifier
                  (identifier)))))))
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (unaryExpr
                  (variableExpr
                    (identifier))))
              (type
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (binaryExpr
                  (thisExpr)
                  (intLiteral)))))))
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (type
              (qualifiedIdentifier
                (identifier))
              (typeArgumentList
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (unaryExpr
                    (variableExpr
                      (identifier))))
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (binaryExpr
                    (thisExpr)
                    (intLiteral)))))
            (binaryExpr
              (variableExpr
                (identifier))
              (intLiteral)))))))
  (clazz
    (identifier)
    (classBody
      (lineComment)
      (classProperty
        (identifier)
        (typeAnnotation
          (type
            (type
              (qualifiedIdentifier
                (identifier)))
            (methodCallExpr
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList
                    (typedIdentifier
                      (identifier))
                    (typedIdentifier
                      (identifier)))
                  (binaryExpr
                    (isExpr
                      (variableExpr
                        (identifier))
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (unaryExpr
                          (variableExpr
                            (identifier)))))
                    (isExpr
                      (variableExpr
                        (identifier))
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (binaryExpr
                          (thisExpr)
                          (intLiteral)))))))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (methodCallExpr
            (identifier)
            (argumentList
              (slStringLiteral)
              (intLiteral)
              (slStringLiteral)
              (intLiteral)
              (slStringLiteral)
              (intLiteral))))
        (objectProperty
          (identifier)
          (methodCallExpr
            (identifier)
            (argumentList
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral)))))
        (objectProperty
          (identifier)
          (methodCallExpr
            (identifier)
            (argumentList
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))))))))
  (classProperty
    (identifier)
    (newExpr
      (type
        (qualifiedIdentifier
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (methodCallExpr
            (identifier)
            (argumentList
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))
              (slStringLiteral)
              (unaryExpr
                (intLiteral))))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (slStringLiteral))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (slStringLiteral))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (intLiteral)
                      (intLiteral))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (intLiteral)
                      (slStringLiteral)
                      (intLiteral)
                      (slStringLiteral)
                      (intLiteral))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (intLiteral)
                      (slStringLiteral)
                      (intLiteral)
                      (slStringLiteral)
                      (intLiteral))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral)))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral)))))))
            (identifier))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (propertyCallExpr
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectProperty
                  (identifier)
                  (methodCallExpr
                    (identifier)
                    (argumentList
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral))
                      (slStringLiteral)
                      (unaryExpr
                        (intLiteral)))))))
            (identifier)))))))
