================================================================================
listings/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 listing1 = new Listing { "one" }
    local listing2 = new Listing { x; local x = "one" }
    local listing3 = new Listing { x; local x = "one" } { [0] = y; local y = "one" }
    
    set.add(listing1).contains(listing2)
    set.add(listing2).contains(listing3)
    set.add(listing3).contains(listing2)
    set.add(listing1).add(listing2).add(listing3).length == 101
  }
  
  ["hidden members aren't included in hash code"] {
    local listing1 = new Listing { "one" }
    local listing2 = new Listing { "one"; default = (_) -> 42 }

    set.add(listing1).contains(listing2)
    set.add(listing2).contains(listing1)
    set.add(listing1).add(listing2).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
                (objectElement
                  (slStringLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectElement
                  (variableExpr
                    (identifier)))
                (objectProperty
                  (modifier)
                  (identifier)
                  (slStringLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (objectLiteral
              (newExpr
                (type
                  (qualifiedIdentifier
                    (identifier)))
                (objectBody
                  (objectElement
                    (variableExpr
                      (identifier)))
                  (objectProperty
                    (modifier)
                    (identifier)
                    (slStringLiteral))))
              (objectBody
                (objectEntry
                  (intLiteral)
                  (variableExpr
                    (identifier)))
                (objectProperty
                  (modifier)
                  (identifier)
                  (slStringLiteral)))))
          (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
                (objectElement
                  (slStringLiteral)))))
          (objectProperty
            (modifier)
            (identifier)
            (newExpr
              (type
                (qualifiedIdentifier
                  (identifier)))
              (objectBody
                (objectElement
                  (slStringLiteral))
                (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))))))))
