|
|
@ -37,6 +37,7 @@ protected static function TESTS() |
|
|
|
Test_ReferenceManagement(); |
|
|
|
Test_ReferenceManagement(); |
|
|
|
Test_Take(); |
|
|
|
Test_Take(); |
|
|
|
Test_LargeArray(); |
|
|
|
Test_LargeArray(); |
|
|
|
|
|
|
|
Test_Append(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function AcediaObject NewKey(int value) |
|
|
|
protected static function AcediaObject NewKey(int value) |
|
|
@ -570,6 +571,87 @@ protected static function Test_LargeArray() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function Test_Append() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local HashTable main, additive, empty; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main = __().collections.EmptyHashTable(); |
|
|
|
|
|
|
|
additive = __().collections.EmptyHashTable(); |
|
|
|
|
|
|
|
empty = __().collections.EmptyHashTable(); |
|
|
|
|
|
|
|
// Ref count in main = 2, creation and copy into collection |
|
|
|
|
|
|
|
main.SetItem(P("A"), __().text.FromString("value of A")); |
|
|
|
|
|
|
|
main.SetItem(P("B"), __().text.FromString("value of B")); |
|
|
|
|
|
|
|
main.SetItem(P("C"), __().text.FromString("value of C")); |
|
|
|
|
|
|
|
main.SetItem(P("D"), none); |
|
|
|
|
|
|
|
additive.SetItem(P("C"), __().text.FromString("other value of C!")); |
|
|
|
|
|
|
|
additive.SetItem(P("D"), __().text.FromString("value of D")); |
|
|
|
|
|
|
|
additive.SetItem(P("E"), __().text.FromString("value of E")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Context("Testing appending `HashTable`'s."); |
|
|
|
|
|
|
|
SubTest_EmptyCopies(main, additive, empty); |
|
|
|
|
|
|
|
SubTest_ProperCopies(main, additive, empty); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_EmptyCopies( |
|
|
|
|
|
|
|
HashTable main, |
|
|
|
|
|
|
|
HashTable additive, |
|
|
|
|
|
|
|
HashTable empty) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Issue("`Append(none)` changes caller `HashTable`."); |
|
|
|
|
|
|
|
main.Append(none); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetLength() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("A")) == "value of A"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("B")) == "value of B"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("C")) == "value of C"); |
|
|
|
|
|
|
|
TEST_ExpectNone(main.GetItem(P("D"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("`Append()` for empty argument changes caller `HashTable`."); |
|
|
|
|
|
|
|
main.Append(empty); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetLength() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("A")) == "value of A"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("B")) == "value of B"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("C")) == "value of C"); |
|
|
|
|
|
|
|
TEST_ExpectNone(main.GetItem(P("D"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("`Append()` doesn't properly work on empty `HashTable`"); |
|
|
|
|
|
|
|
// Ref count in main = 3, +1 for appending |
|
|
|
|
|
|
|
empty.Append(main); |
|
|
|
|
|
|
|
TEST_ExpectTrue(empty.GetLength() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(empty.GetString(P("A")) == "value of A"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(empty.GetString(P("B")) == "value of B"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(empty.GetString(P("C")) == "value of C"); |
|
|
|
|
|
|
|
TEST_ExpectNone(empty.GetItem(P("D"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_ProperCopies( |
|
|
|
|
|
|
|
HashTable main, |
|
|
|
|
|
|
|
HashTable additive, |
|
|
|
|
|
|
|
HashTable empty) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Issue("`Append()` doesn't properly append `HashTable`s."); |
|
|
|
|
|
|
|
main.Append(additive); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetLength() == 5); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("A")) == "value of A"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("B")) == "value of B"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("C")) == "value of C"); |
|
|
|
|
|
|
|
TEST_ExpectNone(main.GetItem(P("D"))); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetString(P("E")) == "value of E"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("`Append()` changes appended `HashTable`"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(additive.GetLength() == 3); |
|
|
|
|
|
|
|
TEST_ExpectTrue(additive.GetString(P("C")) == "other value of C!"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(additive.GetString(P("D")) == "value of D"); |
|
|
|
|
|
|
|
TEST_ExpectTrue(additive.GetString(P("E")) == "value of E"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("`Append()` incorrectly changes reference counts of items inside" |
|
|
|
|
|
|
|
@ "`HashTable`"); |
|
|
|
|
|
|
|
// Ref count in main = 3, so 4 after getter |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetItem(P("A"))._getRefCount() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetItem(P("B"))._getRefCount() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetItem(P("C"))._getRefCount() == 4); |
|
|
|
|
|
|
|
TEST_ExpectTrue(main.GetItem(P("E"))._getRefCount() == 4); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
defaultproperties |
|
|
|
defaultproperties |
|
|
|
{ |
|
|
|
{ |
|
|
|
caseGroup = "Collections" |
|
|
|
caseGroup = "Collections" |
|
|
|