|
@@ -1,23 +1,23 @@ |
|
|
from memory import * |
|
|
from memory import * |
|
|
from memory_Context import * |
|
|
from memory_Context import * |
|
|
|
|
|
|
|
|
def memory_test_shouldDeselectMismatchedItems( |
|
|
|
|
|
|
|
|
def memory_test_deselectMismatchedItems( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select two items of different groups. |
|
|
# Select two items of different groups. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 2 |
|
|
c.selectedId = 2 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# Detect mismatching. |
|
|
# Detect mismatching. |
|
|
c = memory_shouldDeselectMismatchedItems(c) |
|
|
|
|
|
|
|
|
c = memory_deselectMismatchedItems(c) |
|
|
|
|
|
|
|
|
# See if the two selected items do not match. |
|
|
# See if the two selected items do not match. |
|
|
if ( |
|
|
if ( |
|
@@ -26,28 +26,28 @@ def memory_test_shouldDeselectMismatchedItems( |
|
|
c.mismatchedItems[0] == 0 and |
|
|
c.mismatchedItems[0] == 0 and |
|
|
c.mismatchedItems[1] == 2 |
|
|
c.mismatchedItems[1] == 2 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldDeselectMismatchedItems" |
|
|
|
|
|
|
|
|
return "OK: memory_deselectMismatchedItems" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldDeselectMismatchedItems" |
|
|
|
|
|
|
|
|
return "ERR: memory_deselectMismatchedItems" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldDeselectMismatchedItems_itemTwice( |
|
|
|
|
|
|
|
|
def memory_test_deselectMismatchedItems_itemTwice( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select the same item twice. |
|
|
# Select the same item twice. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# Detect mismatching. |
|
|
# Detect mismatching. |
|
|
c = memory_shouldDeselectMismatchedItems(c) |
|
|
|
|
|
|
|
|
c = memory_deselectMismatchedItems(c) |
|
|
|
|
|
|
|
|
# See if the two selected items do not match. |
|
|
# See if the two selected items do not match. |
|
|
if ( |
|
|
if ( |
|
@@ -55,59 +55,59 @@ def memory_test_shouldDeselectMismatchedItems_itemTwice( |
|
|
len(c.mismatchedItems) == 1 and |
|
|
len(c.mismatchedItems) == 1 and |
|
|
c.mismatchedItems[0] == 0 |
|
|
c.mismatchedItems[0] == 0 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldDeselectMismatchedItems_itemTwice" |
|
|
|
|
|
|
|
|
return "OK: memory_deselectMismatchedItems_itemTwice" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldDeselectMismatchedItems_itemTwice" |
|
|
|
|
|
|
|
|
return "ERR: memory_deselectMismatchedItems_itemTwice" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldDetectVictory( |
|
|
|
|
|
|
|
|
def memory_test_detectVictory( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select the first two items of the same group. |
|
|
# Select the first two items of the same group. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 1 |
|
|
c.selectedId = 1 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# Hide the first pair. |
|
|
# Hide the first pair. |
|
|
c = memory_shouldHideMatchingItems(c) |
|
|
|
|
|
|
|
|
c = memory_hideMatchingItems(c) |
|
|
|
|
|
|
|
|
# Select the last two items of the same group. |
|
|
# Select the last two items of the same group. |
|
|
c.selectedId = 2 |
|
|
c.selectedId = 2 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 3 |
|
|
c.selectedId = 3 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# Hide the second pair. |
|
|
# Hide the second pair. |
|
|
c = memory_shouldHideMatchingItems(c) |
|
|
|
|
|
|
|
|
c = memory_hideMatchingItems(c) |
|
|
|
|
|
|
|
|
# Detect victory. |
|
|
# Detect victory. |
|
|
c = memory_shouldDetectVictory(c) |
|
|
|
|
|
|
|
|
c = memory_detectVictory(c) |
|
|
|
|
|
|
|
|
# See if victory has been detected. |
|
|
# See if victory has been detected. |
|
|
if ( |
|
|
if ( |
|
|
c.recentField == "victory" and |
|
|
c.recentField == "victory" and |
|
|
c.victory == True |
|
|
c.victory == True |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldDetectVictory" |
|
|
|
|
|
|
|
|
return "OK: memory_detectVictory" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldDetectVictory" |
|
|
|
|
|
|
|
|
return "ERR: memory_detectVictory" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldGenerateConstPlayfield( |
|
|
|
|
|
|
|
|
def memory_test_generateConstPlayfield( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
if ( |
|
|
if ( |
|
|
c.recentField == "playfieldItems" and |
|
|
c.recentField == "playfieldItems" and |
|
|
len(c.playfieldItems) == 4 and |
|
|
len(c.playfieldItems) == 4 and |
|
@@ -116,28 +116,28 @@ def memory_test_shouldGenerateConstPlayfield( |
|
|
c.playfieldItems[2] == 1 and |
|
|
c.playfieldItems[2] == 1 and |
|
|
c.playfieldItems[3] == 1 |
|
|
c.playfieldItems[3] == 1 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldGenerateConstPlayfield" |
|
|
|
|
|
|
|
|
return "OK: memory_generateConstPlayfield" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldGenerateConstPlayfield" |
|
|
|
|
|
|
|
|
return "ERR: memory_generateConstPlayfield" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldHideMatchingItems( |
|
|
|
|
|
|
|
|
def memory_test_hideMatchingItems( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select two items of the same group. |
|
|
# Select two items of the same group. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 1 |
|
|
c.selectedId = 1 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# Hide matching items. |
|
|
# Hide matching items. |
|
|
c = memory_shouldHideMatchingItems(c) |
|
|
|
|
|
|
|
|
c = memory_hideMatchingItems(c) |
|
|
|
|
|
|
|
|
# See if the two selected items match. |
|
|
# See if the two selected items match. |
|
|
if ( |
|
|
if ( |
|
@@ -146,22 +146,22 @@ def memory_test_shouldHideMatchingItems( |
|
|
c.hiddenItems[0] == 0 and |
|
|
c.hiddenItems[0] == 0 and |
|
|
c.hiddenItems[1] == 1 |
|
|
c.hiddenItems[1] == 1 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldHideMatchingItems" |
|
|
|
|
|
|
|
|
return "OK: memory_hideMatchingItems" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldHideMatchingItems" |
|
|
|
|
|
|
|
|
return "ERR: memory_hideMatchingItems" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldSelectItem_1x( |
|
|
|
|
|
|
|
|
def memory_test_selectItem_1x( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select the first item. |
|
|
# Select the first item. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# See if it's in selectedItems now. |
|
|
# See if it's in selectedItems now. |
|
|
if ( |
|
|
if ( |
|
@@ -169,25 +169,25 @@ def memory_test_shouldSelectItem_1x( |
|
|
len(c.selectedItems) == 1 and |
|
|
len(c.selectedItems) == 1 and |
|
|
c.selectedItems[0] == 0 |
|
|
c.selectedItems[0] == 0 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldSelectItem_1x" |
|
|
|
|
|
|
|
|
return "OK: memory_selectItem_1x" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldSelectItem_1x" |
|
|
|
|
|
|
|
|
return "ERR: memory_selectItem_1x" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldSelectItem_2x( |
|
|
|
|
|
|
|
|
def memory_test_selectItem_2x( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select the first two items. |
|
|
# Select the first two items. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 1 |
|
|
c.selectedId = 1 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# See if both items are selected now. |
|
|
# See if both items are selected now. |
|
|
if ( |
|
|
if ( |
|
@@ -196,28 +196,28 @@ def memory_test_shouldSelectItem_2x( |
|
|
c.selectedItems[0] == 0 and |
|
|
c.selectedItems[0] == 0 and |
|
|
c.selectedItems[1] == 1 |
|
|
c.selectedItems[1] == 1 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldSelectItem_2x" |
|
|
|
|
|
|
|
|
return "OK: memory_selectItem_2x" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldSelectItem_2x" |
|
|
|
|
|
|
|
|
return "ERR: memory_selectItem_2x" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
def memory_test_shouldSelectItem_3x( |
|
|
|
|
|
|
|
|
def memory_test_selectItem_3x( |
|
|
) -> str: |
|
|
) -> str: |
|
|
c = memory_createContext() |
|
|
c = memory_createContext() |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
c.recentField = "playfieldSize" |
|
|
c.recentField = "playfieldSize" |
|
|
c = memory_shouldGenerateConstPlayfield(c) |
|
|
|
|
|
|
|
|
c = memory_generateConstPlayfield(c) |
|
|
|
|
|
|
|
|
# Select three items. |
|
|
# Select three items. |
|
|
c.selectedId = 0 |
|
|
c.selectedId = 0 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 1 |
|
|
c.selectedId = 1 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
c.selectedId = 2 |
|
|
c.selectedId = 2 |
|
|
c.recentField = "selectedId" |
|
|
c.recentField = "selectedId" |
|
|
c = memory_shouldSelectItem(c) |
|
|
|
|
|
|
|
|
c = memory_selectItem(c) |
|
|
|
|
|
|
|
|
# See if only one (last) item is selected now. |
|
|
# See if only one (last) item is selected now. |
|
|
if ( |
|
|
if ( |
|
@@ -225,7 +225,7 @@ def memory_test_shouldSelectItem_3x( |
|
|
len(c.selectedItems) == 1 and |
|
|
len(c.selectedItems) == 1 and |
|
|
c.selectedItems[0] == 2 |
|
|
c.selectedItems[0] == 2 |
|
|
): |
|
|
): |
|
|
return "OK: memory_shouldSelectItem_3x" |
|
|
|
|
|
|
|
|
return "OK: memory_selectItem_3x" |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_shouldSelectItem_3x" |
|
|
|
|
|
|
|
|
return "ERR: memory_selectItem_3x" |
|
|
#} |
|
|
#} |