def run(): global item, item2, item7, item4, item3, item6, item5 item = BlocklyMethods.createListWithItem(0, 5) item2 = BlocklyMethods.createListWithItem(True, 5) item3 = BlocklyMethods.createListWithItem("", 5) item4 = BlocklyMethods.createListWithItem('white', 5) item5 = BlocklyMethods.createListWithItem(hal.waitForConnection(), 5) item = BlocklyMethods.listsGetSubList(item, 'from_start', 0, 'from_start', 0) item2 = BlocklyMethods.listsGetSubList(item2, 'from_start', 0, 'from_start', 0) item3 = BlocklyMethods.listsGetSubList(item3, 'from_start', 0, 'from_start', 0) item4 = BlocklyMethods.listsGetSubList(item4, 'from_start', 0, 'from_start', 0) item5 = BlocklyMethods.listsGetSubList(item5, 'from_start', 0, 'from_start', 0) item6 = BlocklyMethods.findFirst(item, 0) item6 = BlocklyMethods.findFirst(item2, True) item6 = BlocklyMethods.findFirst(item3, "") item6 = BlocklyMethods.findFirst(item4, 'white') item6 = BlocklyMethods.findFirst(item5, hal.waitForConnection()) item6 = BlocklyMethods.findLast(item, 0) item6 = BlocklyMethods.findLast(item2, True) item6 = BlocklyMethods.findLast(item3, "") item6 = BlocklyMethods.findLast(item4, 'white') item6 = BlocklyMethods.findLast(item5, hal.waitForConnection())
def test_findLast_Found(self): res = BlocklyMethods.findLast(['a', 'b', 'b', 'c'], 'b') self.assertEqual(2, res)
def test_findLast_NotFound(self): res = BlocklyMethods.findLast(['a', 'b', 'b', 'd'], 'x') self.assertEqual(-1, res)