local ____lualib = require("lualib_bundle")
local __TS__TypeOf = ____lualib.__TS__TypeOf
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local Set = ____lualib.Set
local ____exports = {}
local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand, copiedSerializedMapHasStringKey, copiedSerializedMapHasNumberKey, copiedSerializedDefaultMapHasStringKey, copiedSerializedDefaultMapHasNumberKey
local ____DefaultMap = require("classes.DefaultMap")
local DefaultMap = ____DefaultMap.DefaultMap
local ____SerializationBrand = require("enums.private.SerializationBrand")
local SerializationBrand = ____SerializationBrand.SerializationBrand
local ____SerializationType = require("enums.SerializationType")
local SerializationType = ____SerializationType.SerializationType
local ____array = require("functions.array")
local arrayEquals = ____array.arrayEquals
local ____deepCopy = require("functions.deepCopy")
local deepCopy = ____deepCopy.deepCopy
local ____log = require("functions.log")
local log = ____log.log
local ____tstlClass = require("functions.tstlClass")
local isDefaultMap = ____tstlClass.isDefaultMap
local isTSTLMap = ____tstlClass.isTSTLMap
local isTSTLSet = ____tstlClass.isTSTLSet
local ____types = require("functions.types")
local isNumber = ____types.isNumber
local isString = ____types.isString
local isTable = ____types.isTable
function copiedObjectIsTable(self)
    local oldObject = {abc = "def"}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectIsTable")
    if not isTable(nil, newObject) then
        error("The copied object had a type of: " .. __TS__TypeOf(newObject))
    end
end
function copiedObjectHasKeyAndValueString(self)
    local keyToLookFor = "abc"
    local valueToLookFor = "def"
    local oldObject = {abc = valueToLookFor}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasKeyAndValueString")
    local value = newObject[keyToLookFor]
    if value == nil then
        error("The copied object did not have a key of: " .. keyToLookFor)
    end
    if not isString(nil, value) then
        error("The copied object had a value type of: " .. __TS__TypeOf(value))
    end
    if value ~= valueToLookFor then
        error("The copied object had a value of: " .. value)
    end
end
function copiedTableHasKeyAndValueNumber(self)
    local keyToLookFor = 123
    local valueToLookFor = 456
    local oldTable = {}
    oldTable[keyToLookFor] = valueToLookFor
    local newTable = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableHasKeyAndValueNumber")
    local value = newTable[keyToLookFor]
    if value == nil then
        error("The copied object did not have a key of: " .. tostring(keyToLookFor))
    end
    if not isNumber(nil, value) then
        error("The copied object had a value type of: " .. __TS__TypeOf(value))
    end
    if value ~= valueToLookFor then
        error("The copied object had a value of: " .. tostring(value))
    end
end
function copiedTableDoesNotCoerceTypes(self)
    local keyToLookFor = 123
    local valueToLookFor = 456
    local oldTable = {}
    oldTable[keyToLookFor] = valueToLookFor
    local newTable = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableDoesNotCoerceTypes")
    local keyString = tostring(keyToLookFor)
    local valueString = tostring(valueToLookFor)
    local valueFromString = newTable[keyString]
    if valueFromString ~= nil then
        error("The copied object had a string key of: " .. keyString)
    end
    local value = newTable[keyToLookFor]
    if value == valueString then
        error("The copied object had a value that incorrectly matched the string of: " .. valueString)
    end
end
function copiedObjectHasNoReferencesForPrimitivesForward(self)
    local originalStringValue = "abcdef"
    local originalNumberValue = 123
    local oldObject = {abc = originalStringValue, def = originalNumberValue}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesForward")
    oldObject.abc = "newValue"
    if oldObject.abc == newObject.abc then
        error("The copied object has a string reference going forward.")
    end
    oldObject.def = 456
    if oldObject.def == newObject.def then
        error("The copied object has a number reference going forward.")
    end
end
function copiedObjectHasNoReferencesForPrimitivesBackward(self)
    local originalStringValue = "abcdef"
    local originalNumberValue = 123
    local oldObject = {abc = originalStringValue, def = originalNumberValue}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesBackward")
    newObject.abc = "newValue"
    if newObject.abc == oldObject.abc then
        error("The copied object has a string reference going backward.")
    end
    newObject.def = 456
    if newObject.def == oldObject.def then
        error("The copied object has a number reference going backward.")
    end
end
function copiedObjectHasNoReferencesForArray(self)
    local oldObject = {abc = {1, 2, 3}}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForArray")
    if oldObject.abc == newObject.abc then
        error("The copied object has the same point to the child array.")
    end
    if not arrayEquals(nil, oldObject.abc, newObject.abc) then
        error("The copied object does not have an equal array.")
    end
    local ____oldObject_abc_0, ____1_1 = oldObject.abc, 1
    ____oldObject_abc_0[____1_1] = ____oldObject_abc_0[____1_1] + 1
    if arrayEquals(nil, oldObject.abc, newObject.abc) then
        error("The copied object has an equal array after a modification to the old array.")
    end
    local ____oldObject_abc_2, ____1_3 = oldObject.abc, 1
    ____oldObject_abc_2[____1_3] = ____oldObject_abc_2[____1_3] - 1
    local ____newObject_abc_4, ____1_5 = newObject.abc, 1
    ____newObject_abc_4[____1_5] = ____newObject_abc_4[____1_5] + 1
    if arrayEquals(nil, oldObject.abc, newObject.abc) then
        error("The copied object has an equal array after a modification to the new array.")
    end
    local ____newObject_abc_6, ____1_7 = newObject.abc, 1
    ____newObject_abc_6[____1_7] = ____newObject_abc_6[____1_7] - 1
end
function copiedObjectHasChildObject(self)
    local childObjectIndex = "abc"
    local keyToLookFor = "def"
    local valueToLookFor = "ghi"
    local oldObject = {abc = {def = valueToLookFor}}
    local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasChildObject")
    local childObject = newObject[childObjectIndex]
    if childObject == nil then
        error("Failed to find the child object at index: " .. childObjectIndex)
    end
    if not isTable(nil, childObject) then
        error("The copied child object had a type of: " .. __TS__TypeOf(childObject))
    end
    local value = childObject[keyToLookFor]
    if value == nil then
        error("The child object did not have a key of: " .. keyToLookFor)
    end
    if not isString(nil, value) then
        error("The child object value had a type of: " .. __TS__TypeOf(value))
    end
    if value ~= valueToLookFor then
        error("The child object value was: " .. valueToLookFor)
    end
end
function copiedMapIsMap(self)
    local keyToLookFor = "abc"
    local valueToLookFor = "def"
    local oldMap = __TS__New(Map, {{keyToLookFor, valueToLookFor}})
    local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapIsMap")
    if not isTSTLMap(nil, newMap) then
        error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
    end
end
function copiedMapHasValue(self)
    local keyToLookFor = "abc"
    local valueToLookFor = "def"
    local oldMap = __TS__New(Map, {{keyToLookFor, valueToLookFor}})
    local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasValue")
    if not isTSTLMap(nil, newMap) then
        error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
    end
    local value = newMap:get(keyToLookFor)
    if value == nil then
        error("The copied Map did not have a key of: " .. keyToLookFor)
    end
    if value ~= valueToLookFor then
        error("The copied Map did not have a value of: " .. valueToLookFor)
    end
end
function copiedSetIsSet(self)
    local valueToLookFor = "abc"
    local oldSet = __TS__New(Set, {valueToLookFor})
    local newSet = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetIsSet")
    if not isTSTLSet(nil, newSet) then
        error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
    end
end
function copiedSetHasValue(self)
    local valueToLookFor = "abc"
    local oldSet = __TS__New(Set, {valueToLookFor})
    local newSet = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetHasValue")
    if not isTSTLSet(nil, newSet) then
        error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
    end
    local hasValue = newSet:has(valueToLookFor)
    if not hasValue then
        error("The copied Set did not have a value of: " .. valueToLookFor)
    end
end
function copiedMapHasChildMap(self)
    local childMapKey = 123
    local childMapValue = 456
    local oldChildMap = __TS__New(Map, {{childMapKey, childMapValue}})
    local keyToLookFor = "childMap"
    local oldMap = __TS__New(Map, {{keyToLookFor, oldChildMap}})
    local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasChildMap")
    if not isTSTLMap(nil, newMap) then
        error("The copied Map was not a Map and had a type of: " .. __TS__TypeOf(newMap))
    end
    local newChildMap = newMap:get(keyToLookFor)
    if newChildMap == nil then
        error("The copied Map did not have a child map at key: " .. keyToLookFor)
    end
    if not isTSTLMap(nil, newChildMap) then
        error("The copied child Map was not a Map and had a type of: " .. __TS__TypeOf(newChildMap))
    end
    local value = newChildMap:get(childMapKey)
    if value == nil then
        error("The copied child Map did not have a key of: " .. tostring(childMapKey))
    end
    if value ~= childMapValue then
        error("The copied child Map did not have a value of: " .. tostring(childMapValue))
    end
end
function copiedDefaultMapHasChildDefaultMap(self)
    local parentMapKey = "abc"
    local childMapKey1 = 123
    local childMapKey2 = 456
    local childMapDefaultValue = 1
    local childMapCustomValue = 2
    local oldParentMap = __TS__New(
        DefaultMap,
        function() return __TS__New(DefaultMap, childMapDefaultValue) end
    )
    local oldChildMap = oldParentMap:getAndSetDefault(parentMapKey)
    oldChildMap:getAndSetDefault(childMapKey1)
    oldChildMap:set(childMapKey2, childMapCustomValue)
    local newParentMap = deepCopy(nil, oldParentMap, SerializationType.NONE, "copiedDefaultMapHasChildDefaultMap")
    if not isDefaultMap(nil, newParentMap) then
        error("The copied parent DefaultMap was not a DefaultMap and had a type of: " .. __TS__TypeOf(newParentMap))
    end
    local newChildMap = newParentMap:get(parentMapKey)
    if newChildMap == nil then
        error("The copied DefaultMap did not have a child map at key: " .. parentMapKey)
    end
    if not isDefaultMap(nil, newChildMap) then
        error("The copied child DefaultMap was not a DefaultMap and had a type of: " .. __TS__TypeOf(newChildMap))
    end
    local newChildMapValue1 = newChildMap:get(childMapKey1)
    if newChildMapValue1 == nil then
        error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey1))
    end
    if newChildMapValue1 ~= childMapDefaultValue then
        error("The copied child Map did not have a default value of: " .. tostring(childMapDefaultValue))
    end
    local newChildMapValue2 = newChildMap:get(childMapKey2)
    if newChildMapValue2 == nil then
        error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey2))
    end
    if newChildMapValue2 ~= childMapCustomValue then
        error("The copied child Map did not have a custom value of: " .. tostring(childMapCustomValue))
    end
end
function copiedDefaultMapHasBrand(self)
    local oldDefaultValue = "foo"
    local oldDefaultMap = __TS__New(DefaultMap, oldDefaultValue)
    local newTable = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedDefaultMapHasBrand")
    if not isTable(nil, newTable) then
        error("The copied DefaultMap was not a table and had a type of: " .. __TS__TypeOf(newTable))
    end
    if not (newTable[SerializationBrand.DEFAULT_MAP] ~= nil) then
        error("The copied DefaultMap does not have the brand: " .. SerializationBrand.DEFAULT_MAP)
    end
end
function copiedSerializedMapHasStringKey(self)
    local mapKey = "123"
    local mapValue = 456
    local oldMap = __TS__New(Map, {{mapKey, mapValue}})
    local serializedOldMap = deepCopy(nil, oldMap, SerializationType.SERIALIZE, "copiedSerializedMapHasStringKey-serialize")
    local newTable = deepCopy(nil, serializedOldMap, SerializationType.DESERIALIZE, "copiedSerializedMapHasStringKey-deserialize")
    local newMap = newTable
    if not newMap:has(mapKey) then
        local keyType = type(mapKey)
        error((("The copied Map did not have a key of: " .. mapKey) .. " with type ") .. keyType)
    end
end
function copiedSerializedMapHasNumberKey(self)
    local mapKey = 123
    local mapValue = 456
    local oldMap = __TS__New(Map, {{mapKey, mapValue}})
    local serializedOldMap = deepCopy(nil, oldMap, SerializationType.SERIALIZE, "copiedSerializedMapHasNumberKey-serialize")
    local newTable = deepCopy(nil, serializedOldMap, SerializationType.DESERIALIZE, "copiedSerializedMapHasNumberKey-deserialize")
    local newMap = newTable
    if not newMap:has(mapKey) then
        local keyType = type(mapKey)
        error((("The copied Map did not have a key of: " .. tostring(mapKey)) .. " with type ") .. keyType)
    end
end
function copiedSerializedDefaultMapHasStringKey(self)
    local mapKey = "123"
    local oldDefaultMap = __TS__New(DefaultMap, 456)
    oldDefaultMap:getAndSetDefault(mapKey)
    local serializedOldDefaultMap = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedSerializedDefaultMapHasStringKey-serialize")
    local newTable = deepCopy(nil, serializedOldDefaultMap, SerializationType.DESERIALIZE, "copiedSerializedDefaultMapHasStringKey-deserialize")
    local newDefaultMap = newTable
    if not newDefaultMap:has(mapKey) then
        local keyType = type(mapKey)
        error((("The copied DefaultMap did not have a key of \"" .. mapKey) .. "\" with type: ") .. keyType)
    end
end
function copiedSerializedDefaultMapHasNumberKey(self)
    local mapKey = 123
    local oldDefaultMap = __TS__New(DefaultMap, 456)
    oldDefaultMap:getAndSetDefault(mapKey)
    local serializedOldDefaultMap = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedSerializedDefaultMapHasNumberKey-serialize")
    local newTable = deepCopy(nil, serializedOldDefaultMap, SerializationType.DESERIALIZE, "copiedSerializedDefaultMapHasNumberKey-deserialize")
    local newDefaultMap = newTable
    if not newDefaultMap:has(mapKey) then
        local keyType = type(mapKey)
        error((("The copied DefaultMap did not have a key of: " .. tostring(mapKey)) .. " with type ") .. keyType)
    end
end
--- Run the suite of tests that prove that the "deepCopy" helper function works properly.
-- 
-- This function is only useful if you are troubleshooting the "deepCopy" function.
function ____exports.runDeepCopyTests(self)
    copiedObjectIsTable(nil)
    copiedObjectHasKeyAndValueString(nil)
    copiedTableHasKeyAndValueNumber(nil)
    copiedTableDoesNotCoerceTypes(nil)
    copiedObjectHasNoReferencesForPrimitivesForward(nil)
    copiedObjectHasNoReferencesForPrimitivesBackward(nil)
    copiedObjectHasNoReferencesForArray(nil)
    copiedObjectHasChildObject(nil)
    copiedMapIsMap(nil)
    copiedMapHasValue(nil)
    copiedSetIsSet(nil)
    copiedSetHasValue(nil)
    copiedMapHasChildMap(nil)
    copiedDefaultMapHasChildDefaultMap(nil)
    copiedDefaultMapHasBrand(nil)
    copiedSerializedMapHasStringKey(nil)
    copiedSerializedMapHasNumberKey(nil)
    copiedSerializedDefaultMapHasStringKey(nil)
    copiedSerializedDefaultMapHasNumberKey(nil)
    local successText = "All deep copy tests passed!"
    log(successText)
    print(successText)
end
return ____exports
