================================================================================
mappings/hashCode
================================================================================

amends "../snippetTest.pkl"

facts {
  local set: Set<Int> = IntSeq(1, 100).fold(Set(), (res, n) -> res.add(n))
  
  ["local members aren't included in hash code"] {
    local mapping1 = new Mapping { ["one"] = 1 }
    local mapping2 = new Mapping { ["one"] = x; local x = 1 }
    local mapping3 = new Mapping { ["one"] = x; local x = 1 } { ["one"] = y; local y = 1 }
    
    set.add(mapping1).contains(mapping2)
    set.add(mapping2).contains(mapping3)
    set.add(mapping3).contains(mapping2)
    set.add(mapping1).add(mapping2).add(mapping3).length == 101
  }

  ["hidden members aren't included in hash code"] {
    local mapping1 = new Mapping { ["one"] = 1 }
    local mapping2 = new Mapping { ["one"] = 1; default = (_) -> 42 }

    set.add(mapping1).contains(mapping2)
    set.add(mapping2).contains(mapping1)
    set.add(mapping1).add(mapping2).length == 101
  }
}

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

(module
  (moduleHeader
    (extendsOrAmendsClause
      (stringConstant)))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (modifier)
        (identifier)
        (typeAnnotation
          (type
            (qualifiedIdentifier
              (identifier))
            (typeArgumentList
              (type
                (qualifiedIdentifier
                  (identifier))))))
        (methodCallExpr
          (methodCallExpr
            (identifier)
            (argumentList
              (intLiteral)
              (intLiteral)))
          (identifier)
          (argumentList
            (methodCallExpr
              (identifier)
              (argumentList))
            (functionLiteral
              (parameterList
                (typedIdentifier
                  (identifier))
                (typedIdentifier
                  (identifier)))
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (intLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (variableExpr
                    (identifier)))
                (objectProperty
                  (modifier)
                  (identifier)
                  (intLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (objectLiteral
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody
                  (objectEntry
                    (slStringLiteral)
                    (variableExpr
                      (identifier)))
                  (objectProperty
                    (modifier)
                    (identifier)
                    (intLiteral))))
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (variableExpr
                    (identifier)))
                (objectProperty
                  (modifier)
                  (identifier)
                  (intLiteral)))))
          (objectElement
            (methodCallExpr
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (variableExpr
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (variableExpr
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (variableExpr
                  (identifier)))))
          (objectElement
            (binaryExpr
              (propertyCallExpr
                (methodCallExpr
                  (methodCallExpr
                    (methodCallExpr
                      (variableExpr
                        (identifier))
                      (identifier)
                      (argumentList
                        (variableExpr
                          (identifier))))
                    (identifier)
                    (argumentList
                      (variableExpr
                        (identifier))))
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier))))
                (identifier))
              (intLiteral)))))
      (objectEntry
        (slStringLiteral)
        (objectBody
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (intLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectEntry
                  (slStringLiteral)
                  (intLiteral))
                (objectProperty
                  (identifier)
                  (functionLiteral
                    (parameterList
                      (typedIdentifier
                        (identifier)))
                    (intLiteral))))))
          (objectElement
            (methodCallExpr
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (variableExpr
                  (identifier)))))
          (objectElement
            (methodCallExpr
              (methodCallExpr
                (variableExpr
                  (identifier))
                (identifier)
                (argumentList
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (variableExpr
                  (identifier)))))
          (objectElement
            (binaryExpr
              (propertyCallExpr
                (methodCallExpr
                  (methodCallExpr
                    (variableExpr
                      (identifier))
                    (identifier)
                    (argumentList
                      (variableExpr
                        (identifier))))
                  (identifier)
                  (argumentList
                    (variableExpr
                      (identifier))))
                (identifier))
              (intLiteral))))))))
