Best Python code snippet using tempest_python
test_sll.py
Source:test_sll.py  
...30        test_list = ['M', 'q', 20, 'A']31        my_sll = self.create_sll(test_list)32        expected_len = len(test_list)33        actual_len = Module.length(my_sll)34        msg = "%s: Expected length('%s') to return %d, got %d" % (ModuleName, Module.__str__(my_sll), expected_len, actual_len)35        self.assertEqual(actual_len, expected_len, msg)36    def test_length2(self):37        """Check that len() works on an empty list."""38        test_list = []39        my_sll = self.create_sll(test_list)40        expected_len = len(test_list)41        actual_len = Module.length(my_sll)42        msg = "%s: Expected length('%s') to return %d, got %d" % (ModuleName, Module.__str__(my_sll), expected_len, actual_len)43        self.assertEqual(actual_len, expected_len, msg)44    def test_length3(self):45        """Check that length() works."""46        test_list = ['M']47        my_sll = self.create_sll(test_list)48        expected_len = len(test_list)49        actual_len = Module.length(my_sll)50        msg = "%s: Expected length('%s') to return %d, got %d" % (ModuleName, Module.__str__(my_sll), expected_len, actual_len)51        self.assertEqual(actual_len, expected_len, msg)52    def test_add_front(self):53        """Check that add_front() works for empty SLL."""54        test_list = []55        old_sll = self.create_sll(test_list)56        new_sll = Module.add_front(old_sll, 'A')57        expected_list = ['A']58        expected = self.create_sll(expected_list)59        msg = "%s: Expected add_front(%s, 'A') to return %s, got %s" % (ModuleName, Module.__str__(old_sll),60                                                                        Module.__str__(expected),61                                                                        Module.__str__(new_sll))62        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)63    def test_add_front2(self):64        """Check that add_front() works on SLL with one element."""65        test_list = [20]66        old_sll = self.create_sll(test_list)67        new_sll = Module.add_front(old_sll, 'M')68        expected_list = ['M', 20]69        expected = self.create_sll(expected_list)70        msg = "%s: Expected add_front(%s, 'M') to return %s, got %s" % (ModuleName, Module.__str__(old_sll),71                                                                        Module.__str__(expected),72                                                                        Module.__str__(new_sll))73        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)74    def test_add_front3(self):75        """Check that add_front() works on SLL with many elements."""76        test_list = [20, 'A', 'omega']77        old_sll = self.create_sll(test_list)78        new_sll = Module.add_front(old_sll, 'M')79        expected_list = ['M', 20, 'A', 'omega']80        expected = self.create_sll(expected_list)81        msg = "%s: Expected add_front(%s, 'M') to return %s, got %s" % (ModuleName, Module.__str__(old_sll),82                                                                        Module.__str__(expected),83                                                                        Module.__str__(new_sll))84        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)85    def test_add_front4(self):86        """Check that add_front() works repeatedly on SLL with no elements."""87        test_list = []88        old_sll = self.create_sll(test_list)89        new_sll = Module.add_front(old_sll, 'first')90        expected_list = ['first']91        expected = self.create_sll(expected_list)92        msg = ("%s: add_front(%s, 'first') returned %s, expected %s"93                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))94        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)95        new_sll = Module.add_front(new_sll, 'second')96        expected_list = ['second', 'first']97        expected = self.create_sll(expected_list)98        msg = ("%s: add_front(%s, 'second') returned %s, expected %s"99                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))100        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)101        new_sll = Module.add_front(new_sll, 'third')102        expected_list = ['third', 'second', 'first']103        expected = self.create_sll(expected_list)104        msg = ("%s: add_front(%s, 'third') returned %s, expected %s"105                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))106        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)107        new_sll = Module.add_front(new_sll, 'fourth')108        expected_list = ['fourth', 'third', 'second', 'first']109        expected = self.create_sll(expected_list)110        msg = ("%s: add_front(%s, 'fourth') returned %s, expected %s"111                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))112        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)113    def test_add_back(self):114        """Check that add_back() works for empty SLL."""115        test_list = []116        old_sll = self.create_sll(test_list)117        new_sll = Module.add_back(old_sll, 'A')118        expected_list = ['A']119        expected = self.create_sll(expected_list)120        msg = ("%s: add_back(%s, 'A') returned %s, expected %s"121                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))122        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)123    def test_add_back2(self):124        """Check that add_back() works on SLL with one element."""125        test_list = [20]126        old_sll = self.create_sll(test_list)127        new_sll = Module.add_back(old_sll, 'M')128        expected_list = [20, 'M']129        expected = self.create_sll(expected_list)130        msg = ("%s: add_back(%s, 'M') returned %s, expected %s"131                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))132        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)133    def test_add_back3(self):134        """Check that add_back() works on SLL with many elements."""135        test_list = [20, 'A', 'omega']136        old_sll = self.create_sll(test_list)137        new_sll = Module.add_back(old_sll, 'M')138        expected_list = [20, 'A', 'omega', 'M']139        expected = self.create_sll(expected_list)140        msg = ("%s: add_back(%s, 'M') returned %s, expected %s"141                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))142        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)143    def test_add_back4(self):144        """Check that add_back() works repeatedly on SLL with no elements."""145        test_list = []146        old_sll = self.create_sll(test_list)147        new_sll = Module.add_back(old_sll, 'first')148        expected_list = ['first']149        expected = self.create_sll(expected_list)150        msg = ("%s: add_back(%s, 'first') returned %s, expected %s"151                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))152        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)153        new_sll = Module.add_back(new_sll, 'second')154        expected_list = ['first', 'second']155        expected = self.create_sll(expected_list)156        msg = ("%s: add_back(%s, 'second') returned %s, expected %s"157                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))158        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)159        new_sll = Module.add_back(new_sll, 'third')160        expected_list = ['first', 'second', 'third']161        expected = self.create_sll(expected_list)162        msg = ("%s: add_back(%s, 'third') returned %s, expected %s"163                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))164        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)165        new_sll = Module.add_back(new_sll, 'fourth')166        expected_list = ['first', 'second', 'third', 'fourth']167        expected = self.create_sll(expected_list)168        msg = ("%s: add_back(%s, 'fourth') returned %s, expected %s"169                % (ModuleName, Module.__str__(old_sll), Module.__str__(new_sll), Module.__str__(expected)))170        self.assertEqual(Module.__str__(new_sll), Module.__str__(expected), msg)171    def test_find(self):172        """Check that find() works on an empty SLL."""173        test_list = []174        my_sll = self.create_sll(test_list)175        find = Module.find(my_sll, 20)176        msg = "%s: Expected to not find 20 in SLL '%s', failed" % (ModuleName, Module.__str__(my_sll))177        self.assertFalse(find is not None, msg)178    def test_find2(self):179        """Check that find() works on an non-empty SLL."""180        test_list = ['A', 20, 'q', 'M']181        my_sll = self.create_sll(test_list)182        find = Module.find(my_sll, 20)183        msg = "%s: Expected to find 20 in SLL '%s', failed" % (ModuleName, Module.__str__(my_sll))184        self.assertTrue(find is not None, msg)185        # check the sub-SLL returned is correct186        expected = self.create_sll(test_list[1:])187        msg = ("%s: find('%s', 20) returned '%s', expected '%s'"188               % (ModuleName, Module.__str__(my_sll), Module.__str__(find), Module.__str__(expected)))189        self.assertTrue(Module.__str__(find) == Module.__str__(expected), msg)190    def test_find3(self):191        """Check that find() works on an non-empty SLL with multiple finds."""192        test_list = ['A', 20, 'q', 20, 'M']193        my_sll = self.create_sll(test_list)194        find = Module.find(my_sll, 20)195        msg = "%s: Expected to find 20 in SLL '%s', failed" % (ModuleName, Module.__str__(my_sll))196        self.assertTrue(find is not None, msg)197        # check returned sub-SLL is as expected198        expected = self.create_sll(test_list[1:])199        msg = ("%s: find('%s', 20) returned '%s', expected '%s'"200               % (ModuleName, Module.__str__(my_sll), Module.__str__(find), Module.__str__(expected)))201        self.assertTrue(Module.__str__(find) == Module.__str__(expected), msg)202    def test_find4(self):203        """Check that find() works on an non-empty SLL with NO FIND."""204        test_list = ['A', 20, 'q', 20, 'M']205        my_sll = self.create_sll(test_list)206        find = Module.find(my_sll, 'X')207        msg = "%s: Expected to not find 'X' in SLL '%s', succeeded?" % (ModuleName, Module.__str__(my_sll))208        self.assertTrue(find is None, msg)209    def test_add_after(self):210        """Check that add_after() works on an empty SLL."""211        test_list = []212        my_sll = self.create_sll(test_list)213        result = Module.add_after(my_sll, 20, 100)214        msg = "%s: Expected add_after(None, 20, 100) to fail, didn't, got '%s'" % (ModuleName, str(result))215        self.assertTrue(result is None, msg)216    def test_add_after2(self):217        """Check that add_after() works on an SLL with found value."""218        test_list = ['A', 20, 'q', 20, 'M']219        my_sll = self.create_sll(test_list)220        result = Module.add_after(my_sll, 20, 100)221        expected_list = ['A', 20, 100, 'q', 20, 'M']222        expected = self.create_sll(expected_list)223        msg = ("%s: Expected add_after('%s', 20, 100) to return '%s', got '%s'"224               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))225        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)226    def test_add_after3(self):227        """Check that add_after() works on an SLL with NO found value."""228        test_list = ['A', 20, 'q', 20, 'M']229        my_sll = self.create_sll(test_list)230        result = Module.add_after(my_sll, 21, 100)231        expected_list = []232        expected = self.create_sll(expected_list)233        msg = ("%s: Expected add_after('%s', 21, 100) to return None, got '%s'"234               % (ModuleName, Module.__str__(my_sll), Module.__str__(result)))235        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)236    def test_remove(self):237        """Check that remove() works on an empty SLL."""238        test_list = []239        my_sll = self.create_sll(test_list)240        result = None241        expected_list = []242        expected = self.create_sll(expected_list)243        result = Module.remove(my_sll, 21)244        msg = ("%s: Expected remove('%s', 21) to return '%s', got '%s'"245               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))246        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)247    def test_remove2(self):248        """Check that remove() works on an SLL with a found value."""249        test_list = ['A', 20, 'q', 20, 'M']250        my_sll = self.create_sll(test_list)251        result = Module.remove(my_sll, 'q')252        expected_list = ['A', 20, 20, 'M']253        expected = self.create_sll(expected_list)254        msg = ("%s: Expected remove('%s', 21, 100) to return '%s', got '%s'"255               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))256        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)257    def test_remove3(self):258        """Check that remove() works on an SLL with NO found value."""259        test_list = ['A', 20, 'q', 20, 'M']260        my_sll = self.create_sll(test_list)261        result = Module.remove(my_sll, 22)262        expected = my_sll263        msg = ("%s: Expected remove('%s', 21, 100) to return '%s', got '%s'"264               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))265        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)266    def test_remove_first(self):267        """Check that remove_first() works on an empty SLL."""268        test_list = []269        my_sll = self.create_sll(test_list)270        result = Module.remove_first(my_sll)271        expected_list = []272        expected = self.create_sll(expected_list)273        msg = ("%s: Expected remove_first('%s') to return '%s', got '%s'"274               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))275        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)276    def test_remove_first2(self):277        """Check that remove_first() works on a non-empty SLL."""278        test_list = ['A', 20, 'q', 20, 'M']279        my_sll = self.create_sll(test_list)280        result = Module.remove_first(my_sll)281        expected_list = test_list[1:]282        expected = self.create_sll(expected_list)283        msg = ("%s: Expected remove_first('%s') to return '%s', got '%s'"284               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))285        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)286    def test_remove_last(self):287        """Check that remove_last() works on an empty SLL."""288        test_list = []289        my_sll = self.create_sll(test_list)290        result = Module.remove_last(my_sll)291        expected_list = []292        expected = self.create_sll(expected_list)293        msg = ("%s: Expected remove_last('%s') to return '%s', got '%s'"294               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))295        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)296    def test_remove_last2(self):297        """Check that remove_last() works on a non-empty SLL."""298        test_list = ['A', 20, 'q', 20, 'M']299        my_sll = self.create_sll(test_list)300        result = Module.remove_last(my_sll)301        expected_list = test_list[:-1]302        expected = self.create_sll(expected_list)303        msg = ("%s: Expected remove_last('%s') to return '%s', got '%s'"304               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))305        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)306    def test_map_fun(self):307        """Check the map_fun() function."""308        test_list = [1, 2, -3, 5, 100]309        my_sll = self.create_sll(test_list)310        func = lambda x, y: x + y311        result = Module.map_fun(my_sll, func, 1)312        expected_list = [x + 1 for x in test_list]313        expected = self.create_sll(expected_list)314        msg = ("%s: Expected map_fun('%s', func, 1) to return '%s', got '%s'"315               % (ModuleName, Module.__str__(my_sll), Module.__str__(expected), Module.__str__(result)))316        self.assertTrue(Module.__str__(result) == Module.__str__(expected), msg)317if __name__ == '__main__':318    global Module, ModuleName319    suite = unittest.makeSuite(TestSLL,'test')320    runner = unittest.TextTestRunner()321    delim = '*' * 100322    import sll_element323    Module = sll_element324    ModuleName = 'sll_element'325    delim2 = '* %s' % ModuleName326    print('\n%s' % delim)327    print('%s' % delim2)328    print('%s' % delim)329    runner.run(suite)330    import sll_tuple...parser_test.py
Source:parser_test.py  
...11        self.assertRaises(Exception, self.parser.parse, '')1213    def test_parser_recognizes_empty(self):14        self.parser.parse('.')15        self.assertEqual(self.parser.result.__str__(), '.')1617    def test_parser_recognizes_single(self):18        self.parser.parse('a')19        self.assertEqual(self.parser.result.__str__(), 'a')20        21    def test_parser_recognizes_kleene_star_of_empty(self):22        self.parser.parse('.*')23        self.assertEqual(self.parser.result.__str__(), '(k . None)')2425    def test_parser_recognizes_kleene_star_of_one_single(self):26        self.parser.parse('a*')27        self.assertEqual(self.parser.result.__str__(), '(k a None)')2829    def test_parser_recognizes_kleene_star_of_concatenation(self):30        self.parser.parse('(ab)*')31        self.assertEqual(self.parser.result.__str__(), '(k (c a b) None)')3233    def test_parser_recognizes_kleene_star_of_union(self):34        self.parser.parse('(a|b)*')35        self.assertEqual(self.parser.result.__str__(), '(k (u a b) None)')3637    def test_parser_recognizes_kleene_star_of_kleene_star(self):38        self.parser.parse('a**')39        self.assertEqual(self.parser.result.__str__(), '(k (k a None) None)')4041    def test_parser_recognizes_concatenation_of_two_empties(self):42        self.parser.parse('..')43        self.assertEqual(self.parser.result.__str__(), '(c . .)')44        45    def test_parser_recognizes_concatenation_of_empty_and_single(self):46        self.parser.parse('.a')47        self.assertEqual(self.parser.result.__str__(), '(c . a)')48        49    def test_parser_recognizes_concatenation_of_empty_and_union(self):50        self.parser.parse('.(a|b)')51        self.assertEqual(self.parser.result.__str__(), '(c . (u a b))')52        53    def test_parser_recognizes_concatenation_of_empty_and_concatenation(self):54        # TODO: Check this. This can be interpret as concatenation of empty and concatenation or55        # concatenation of concatenation and single56        self.parser.parse('.ab')57        self.assertEqual(self.parser.result.__str__(), '(c (c . a) b)')5859    def test_parser_recognizes_concatenation_of_empty_and_kleene_star(self):60        self.parser.parse('.a*')61        self.assertEqual(self.parser.result.__str__(), '(c . (k a None))')62        63    def test_parser_recognizes_concatenation_of_single_and_empty(self):64        self.parser.parse('a.')65        self.assertEqual(self.parser.result.__str__(), '(c a .)')6667    def test_parser_recognizes_concatenation_of_two_singles(self):68        self.parser.parse('ab')69        self.assertEqual(self.parser.result.__str__(), '(c a b)')7071    def test_parser_recognizes_concatenation_of_single_and_kleene_star(self):72        self.parser.parse('ab*')73        self.assertEqual(self.parser.result.__str__(), '(c a (k b None))')7475    def test_parser_recognizes_concatenation_of_three_singles(self):76        # TODO: Check this. This can be interpret as concatenation of single and concatenation or77        # concatenation of concatenation and single78        self.parser.parse('abc')79        self.assertEqual(self.parser.result.__str__(), '(c (c a b) c)')8081    def test_parser_recognizes_concatenation_of_single_and_union(self):82        self.parser.parse('a(b|c)')83        self.assertEqual(self.parser.result.__str__(), '(c a (u b c))')8485    def test_parser_recognizes_concatenation_of_kleene_star_and_single(self):86        self.parser.parse('a*b')87        self.assertEqual(self.parser.result.__str__(), '(c (k a None) b)')8889    def test_parser_recognizes_concatenation_of_two_kleene_stars(self):90        self.parser.parse('a*b*')91        self.assertEqual(self.parser.result.__str__(), '(c (k a None) (k b None))')9293    def test_parser_recognizes_concatenation_of_kleene_star_and_union(self):94        self.parser.parse('a*(b|c)')95        self.assertEqual(self.parser.result.__str__(), '(c (k a None) (u b c))')9697    def test_parser_recognizes_concatenation_of_concatenation_and_kleene_star(self):98        self.parser.parse('abc*')99        self.assertEqual(self.parser.result.__str__(), '(c (c a b) (k c None))')100101    def test_parser_recognizes_concatenation_of_concatenation_and_union(self):102        self.parser.parse('ab(c|d)')103        self.assertEqual(self.parser.result.__str__(), '(c (c a b) (u c d))')104        105    def test_parser_recognizes_concatenation_of_union_and_empty(self):106        self.parser.parse('(a|b).')107        self.assertEqual(self.parser.result.__str__(), '(c (u a b) .)')108109    def test_parser_recognizes_concatenation_of_union_and_single(self):110        self.parser.parse('(a|b)c')111        self.assertEqual(self.parser.result.__str__(), '(c (u a b) c)')112113    def test_parser_recognizes_concatenation_of_union_and_kleene_star(self):114        self.parser.parse('(a|b)c*')115        self.assertEqual(self.parser.result.__str__(), '(c (u a b) (k c None))')116117    def test_parser_recognizes_concatenation_of_union_and_concatenation(self):118        self.parser.parse('(a|b)cd')119        120        # TODO: Check this. Actually (a|b)cd is concatenation of concatenation of union and single and single121        self.assertEqual(self.parser.result.__str__(), '(c (c (u a b) c) d)')122123    def test_parser_recognizes_concatenation_of_two_unions(self):124        self.parser.parse('(a|b)(c|d)')125        self.assertEqual(self.parser.result.__str__(), '(c (u a b) (u c d))')126        127    def test_parser_recognizes_union_of_two_empties(self):128        self.parser.parse('.|.')129        self.assertEqual(self.parser.result.__str__(), '(u . .)')130        131    def test_parser_recognizes_union_of_empty_and_single(self):132        self.parser.parse('.|a')133        self.assertEqual(self.parser.result.__str__(), '(u . a)')134        135    def test_parser_recognizes_union_of_empty_and_union(self):136        self.parser.parse('.|(a|b)')137        self.assertEqual(self.parser.result.__str__(), '(u . (u a b))')138        139    def test_parser_recognizes_union_of_empty_and_concatenation(self):140        self.parser.parse('.|ab')141        self.assertEqual(self.parser.result.__str__(), '(u . (c a b))')142        143    def test_parser_recognizes_union_of_empty_and_kleen_star(self):144        self.parser.parse('.|a*')145        self.assertEqual(self.parser.result.__str__(), '(u . (k a None))')146147    def test_parser_recognizes_union_of_single_and_empty(self):148        self.parser.parse('a|.')149        self.assertEqual(self.parser.result.__str__(), '(u a .)')150151    def test_parser_recognizes_union_of_two_singles(self):152        self.parser.parse('a|b')153        self.assertEqual(self.parser.result.__str__(), '(u a b)')154155    def test_parser_recognizes_union_of_single_and_kleene_star(self):156        self.parser.parse('a|b*')157        self.assertEqual(self.parser.result.__str__(), '(u a (k b None))')158159    def test_parser_recognizes_union_of_single_and_concatenation(self):160        self.parser.parse('a|bc')161        self.assertEqual(self.parser.result.__str__(), '(u a (c b c))')162163    def test_parser_recognizes_union_of_single_and_union(self):164        self.parser.parse('a|(b|c)')165        self.assertEqual(self.parser.result.__str__(), '(u a (u b c))')166        167    def test_parser_recognizes_union_of_kleene_star_and_empty(self):168        self.parser.parse('a*|.')169        self.assertEqual(self.parser.result.__str__(), '(u (k a None) .)')170171    def test_parser_recognizes_union_of_kleene_star_and_single(self):172        self.parser.parse('a*|b')173        self.assertEqual(self.parser.result.__str__(), '(u (k a None) b)')174175    def test_parser_recognizes_union_of_two_kleene_stars(self):176        self.parser.parse('a*|b*')177        self.assertEqual(self.parser.result.__str__(), '(u (k a None) (k b None))')178179    def test_parser_recognizes_union_of_kleene_star_and_concatenation(self):180        self.parser.parse('a*|bc')181        self.assertEqual(self.parser.result.__str__(), '(u (k a None) (c b c))')182183    def test_parser_recognizes_union_of_kleene_star_and_union(self):184        self.parser.parse('a*|(b|c)')185        self.assertEqual(self.parser.result.__str__(), '(u (k a None) (u b c))')186        187    def test_parser_recognizes_union_of_concatenation_and_empty(self):188        self.parser.parse('ab|.')189        self.assertEqual(self.parser.result.__str__(), '(u (c a b) .)')190191    def test_parser_recognizes_union_of_concatenation_and_single(self):192        self.parser.parse('ab|c')193        self.assertEqual(self.parser.result.__str__(), '(u (c a b) c)')194195    def test_parser_recognizes_union_of_concatenation_and_kleene_star(self):196        self.parser.parse('ab|c*')197        self.assertEqual(self.parser.result.__str__(), '(u (c a b) (k c None))')198199    def test_parser_recognizes_union_of_concatenation_and_concatenation(self):200        self.parser.parse('ab|cd')201        self.assertEqual(self.parser.result.__str__(), '(u (c a b) (c c d))')202203    def test_parser_recognizes_union_of_concatenation_and_union(self):204        self.parser.parse('ab|(c|d)')205        self.assertEqual(self.parser.result.__str__(), '(u (c a b) (u c d))')206        207    def test_parser_recognizes_union_of_union_and_empty(self):208        self.parser.parse('(a|b)|.')209        self.assertEqual(self.parser.result.__str__(), '(u (u a b) .)')210211    def test_parser_recognizes_union_of_union_and_single(self):212        self.parser.parse('(a|b)|c')213        self.assertEqual(self.parser.result.__str__(), '(u (u a b) c)')214215    def test_parser_recognizes_union_of_union_and_kleene_star(self):216        self.parser.parse('(a|b)|c*')217        self.assertEqual(self.parser.result.__str__(), '(u (u a b) (k c None))')218219    def test_parser_recognizes_union_of_union_and_concatenation(self):220        self.parser.parse('(a|b)|cd')221        self.assertEqual(self.parser.result.__str__(), '(u (u a b) (c c d))')222223    def test_parser_recognizes_union_of_union_and_union(self):224        self.parser.parse('(a|b)|(c|d)')225        self.assertEqual(self.parser.result.__str__(), '(u (u a b) (u c d))')226        227    def test_parser_recognizes_lowercase_letters_of_latin_alphabet(self):228        self.parser.parse(alphabet_lowercase_letters)229        self.assertEqual(self.parser.result.__str__(), '(c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c a b) c) d) e) f) g) h) i) j) k) l) m) n) o) p) q) r) s) t) u) v) w) x) y) z)')230        231    def test_parser_recognizes_uppercase_letters_of_latin_alphabet(self):232        self.parser.parse(alphabet_uppercase_letters)233        self.assertEqual(self.parser.result.__str__(), '(c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c (c A B) C) D) E) F) G) H) I) J) K) L) M) N) O) P) Q) R) S) T) U) V) W) X) Y) Z)')234        235    def test_parser_recognizes_digits(self):236        self.parser.parse(alphabet_digits)237        self.assertEqual(self.parser.result.__str__(), '(c (c (c (c (c (c (c (c (c 0 1) 2) 3) 4) 5) 6) 7) 8) 9)')238239    def test_parser_recognizes_concatenation_of_empty_and_double_kleene_star(self):240        self.parser.parse('.a**')241        self.assertEqual(self.parser.result.__str__(), '(c . (k (k a None) None))')242        243    def test_parser_recognizes_concatenation_of_single_and_double_kleene_star(self):244        self.parser.parse('ab**')245        self.assertEqual(self.parser.result.__str__(), '(c a (k (k b None) None))')246        247    def test_parser_recognizes_concatenation_of_concatenation_and_double_kleene_star(self):248        self.parser.parse('abc**')249        self.assertEqual(self.parser.result.__str__(), '(c (c a b) (k (k c None) None))')250        251    def test_parser_recognizes_concatenation_of_union_and_double_kleene_star(self):252        self.parser.parse('(a|b)c**')253        self.assertEqual(self.parser.result.__str__(), '(c (u a b) (k (k c None) None))')254        255    def test_parser_recognizes_concatenation_of_kleene_star_and_double_kleene_star(self):256        self.parser.parse('a*b**')257        self.assertEqual(self.parser.result.__str__(), '(c (k a None) (k (k b None) None))')258        259    def test_parser_recognizes_concatenation_of_two_double_kleene_stars(self):260        self.parser.parse('a**b**')261        self.assertEqual(self.parser.result.__str__(), '(c (k (k a None) None) (k (k b None) None))')262    263    def test_parser_recognizes_concatenation_of_empty_and_unions_kleene_star(self):264        self.parser.parse('.(a|b)*')265        self.assertEqual(self.parser.result.__str__(), '(c . (k (u a b) None))')266    267    def test_parser_recognizes_concatenation_of_single_and_unions_kleene_star(self):268        self.parser.parse('a(b|c)*')269        self.assertEqual(self.parser.result.__str__(), '(c a (k (u b c) None))')270        271    def test_parser_recognizes_concatenation_of_concatenation_and_unions_kleene_star(self):272        self.parser.parse('ab(c|d)*')273        self.assertEqual(self.parser.result.__str__(), '(c (c a b) (k (u c d) None))')274        275    def test_parser_recognizes_concatenation_of_union_and_unions_kleene_star(self):276        self.parser.parse('(a|b)(c|d)*')277        self.assertEqual(self.parser.result.__str__(), '(c (u a b) (k (u c d) None))')278        279    def test_parser_recognizes_concatenation_of_kleene_star_and_unions_kleene_star(self):280        self.parser.parse('a*(b|c)*')281        self.assertEqual(self.parser.result.__str__(), '(c (k a None) (k (u b c) None))')282        283    def test_parser_recognizes_union_of_empty_and_unions_kleene_star(self):284        self.parser.parse('.|(a|b)*')285        self.assertEqual(self.parser.result.__str__(), '(u . (k (u a b) None))')286    287    def test_parser_recognizes_union_of_single_and_unions_kleene_star(self):288        self.parser.parse('a|(b|c)*')289        self.assertEqual(self.parser.result.__str__(), '(u a (k (u b c) None))')290        291    def test_parser_recognizes_union_of_concatenation_and_unions_kleene_star(self):292        self.parser.parse('ab|(c|d)*')293        self.assertEqual(self.parser.result.__str__(), '(u (c a b) (k (u c d) None))')294        295    def test_parser_recognizes_union_of_union_and_unions_kleene_star(self):296        self.parser.parse('(a|b)|(c|d)*')297        self.assertEqual(self.parser.result.__str__(), '(u (u a b) (k (u c d) None))')298        299    def test_parser_recognizes_union_of_kleene_star_and_unions_kleene_star(self):300        self.parser.parse('a*|(b|c)*')301        self.assertEqual(self.parser.result.__str__(), '(u (k a None) (k (u b c) None))')302        303    def test_parser_recognizes_union_of_empty_and_concatenation_of_two_unions(self):304        self.parser.parse('.|(a|b)(c|d)')305        self.assertEqual(self.parser.result.__str__(), '(u . (c (u a b) (u c d)))')306    307    def test_parser_recognizes_union_of_single_and_concatenation_of_two_unions(self):308        self.parser.parse('a|(b|c)(d|e)')309        self.assertEqual(self.parser.result.__str__(), '(u a (c (u b c) (u d e)))')310        311    def test_parser_recognizes_union_of_concatenation_and_concatenation_of_two_unions(self):312        self.parser.parse('ab|(c|d)(e|f)')313        self.assertEqual(self.parser.result.__str__(), '(u (c a b) (c (u c d) (u e f)))')314        315    def test_parser_recognizes_union_of_union_and_concatenation_of_two_unions(self):316        self.parser.parse('(a|b)|(c|d)(e|f)')317        self.assertEqual(self.parser.result.__str__(), '(u (u a b) (c (u c d) (u e f)))')318        319    def test_parser_recognizes_union_of_kleene_star_and_concatenation_of_two_unions(self):320        self.parser.parse('a*|(b|c)(d|e)')
...absmc.py
Source:absmc.py  
...16class Misc_Instruction(Instruction):17    def __init__(self, arg1):18        self.stmt = arg1;19    def __repr__(self):20        return self.__str__()21    def __str__(self):22        return self.stmt23class Label_Instruction(Instruction):24    def __init__(self, arg1):25        self.label = arg1;26    def __repr__(self):27        return self.__str__()28    def __str__(self):29        return self.label30class Move_Immed_i_Instruction(Instruction):31    def __init__(self, ra, rb):32        self.ra = ra33        self.rb = rb34    def __repr__(self):35        return self.__str__()36    def __str__(self):37        return " ".join([INSTRUCTION.MOVE_IMMED_I, str(self.ra), str(self.rb)])38class Move_Immed_f_Instruction(Instruction):39    def __init__(self, ra, rb):40        self.ra = ra41        self.rb = rb42    def __repr__(self):43        return self.__str__()44    def __str__(self):45        return " ".join([INSTRUCTION.MOVE_IMMED_F, str(self.ra), str(self.rb)])46class Move_Instruction(Instruction):47    def __init__(self, ra, rb):48        self.ra = ra49        self.rb = rb50    def __repr__(self):51        return self.__str__()52    def __str__(self):53        return " ".join([INSTRUCTION.MOVE, self.ra, self.rb])54######################################################################55######################################################################56# Definition for integer57class AddInstruction(Instruction):58    def __init__(self, ra, rb, rc):59        self.ra = ra60        self.rb = rb61        self.rc = rc62    def __repr__(self):63        return self.__str__()64    def __str__(self):65        return " ".join([INSTRUCTION.IADD, self.ra, self.rb , self.rc])66class SubInstruction(Instruction):67    def __init__(self, ra, rb, rc):68        self.ra = ra69        self.rb = rb70        self.rc = rc71    def __repr__(self):72        return self.__str__()73    def __str__(self):74        return " ".join([INSTRUCTION.ISUB, self.ra, self.rb , self.rc])75class MulInstruction(Instruction):76    def __init__(self, ra, rb, rc):77        self.ra = ra78        self.rb = rb79        self.rc = rc80    def __repr__(self):81        return self.__str__()82    def __str__(self):83        return " ".join([INSTRUCTION.IMUL, self.ra, self.rb , self.rc])84class DivInstruction(Instruction):85    def __init__(self, ra, rb, rc):86        self.ra = ra87        self.rb = rb88        self.rc = rc89    def __repr__(self):90        return self.__str__()91    def __str__(self):92        return " ".join([INSTRUCTION.IDIV, self.ra, self.rb , self.rc])93class ModInstruction(Instruction):94    def __init__(self, ra, rb, rc):95        self.ra = ra96        self.rb = rb97        self.rc = rc98    def __repr__(self):99        return self.__str__()100    def __str__(self):101        return " ".join([INSTRUCTION.IMOD, self.ra, self.rb , self.rc])102class GtInstruction(Instruction):103    def __init__(self, ra, rb, rc):104        self.ra = ra105        self.rb = rb106        self.rc = rc107    def __repr__(self):108        return self.__str__()109    def __str__(self):110        return " ".join([INSTRUCTION.IGT, self.ra, self.rb , self.rc])111class GeqInstruction(Instruction):112    def __init__(self, ra, rb, rc):113        self.ra = ra114        self.rb = rb115        self.rc = rc116    def __repr__(self):117        return self.__str__()118    def __str__(self):119        return " ".join([INSTRUCTION.IGEQ, self.ra, self.rb , self.rc])120class LtInstruction(Instruction):121    def __init__(self, ra, rb, rc):122        self.ra = ra123        self.rb = rb124        self.rc = rc125    def __repr__(self):126        return self.__str__()127    def __str__(self):128        return " ".join([INSTRUCTION.ILT, self.ra, self.rb , self.rc])129class LeqInstruction(Instruction):130    def __init__(self, ra, rb, rc):131        self.ra = ra132        self.rb = rb133        self.rc = rc134    def __repr__(self):135        return self.__str__()136    def __str__(self):137        return " ".join([INSTRUCTION.ILEQ, self.ra, self.rb , self.rc])138class LtInstruction(Instruction):139    def __init__(self, ra, rb, rc):140        self.ra = ra141        self.rb = rb142        self.rc = rc143    def __repr__(self):144        return self.__str__()145    def __str__(self):146        return " ".join([INSTRUCTION.ILT, self.ra, self.rb , self.rc])147######################################################################148######################################################################149# similar definitions for float150class AddInstructionFloat(Instruction):151    def __init__(self, ra, rb, rc):152        self.ra = ra153        self.rb = rb154        self.rc = rc155    def __repr__(self):156        return self.__str__()157    def __str__(self):158        return " ".join([INSTRUCTION.FADD, self.ra, self.rb , self.rc])159class SubInstructionFloat(Instruction):160    def __init__(self, ra, rb, rc):161        self.ra = ra162        self.rb = rb163        self.rc = rc164    def __repr__(self):165        return self.__str__()166    def __str__(self):167        return " ".join([INSTRUCTION.FSUB, self.ra, self.rb , self.rc])168class MulInstructionFloat(Instruction):169    def __init__(self, ra, rb, rc):170        self.ra = ra171        self.rb = rb172        self.rc = rc173    def __repr__(self):174        return self.__str__()175    def __str__(self):176        return " ".join([INSTRUCTION.FMUL, self.ra, self.rb , self.rc])177class DivInstructionFloat(Instruction):178    def __init__(self, ra, rb, rc):179        self.ra = ra180        self.rb = rb181        self.rc = rc182    def __repr__(self):183        return self.__str__()184    def __str__(self):185        return " ".join([INSTRUCTION.FDIV, self.ra, self.rb , self.rc])186class ModInstructionFloat(Instruction):187    def __init__(self, ra, rb, rc):188        self.ra = ra189        self.rb = rb190        self.rc = rc191    def __repr__(self):192        return self.__str__()193    def __str__(self):194        return " ".join([INSTRUCTION.FMOD, self.ra, self.rb , self.rc])195class GtInstructionFloat(Instruction):196    def __init__(self, ra, rb, rc):197        self.ra = ra198        self.rb = rb199        self.rc = rc200    def __repr__(self):201        return self.__str__()202    def __str__(self):203        return " ".join([INSTRUCTION.FGT, self.ra, self.rb , self.rc])204class GeqInstructionFloat(Instruction):205    def __init__(self, ra, rb, rc):206        self.ra = ra207        self.rb = rb208        self.rc = rc209    def __repr__(self):210        return self.__str__()211    def __str__(self):212        return " ".join([INSTRUCTION.FGEQ, self.ra, self.rb , self.rc])213class LtInstructionFloat(Instruction):214    def __init__(self, ra, rb, rc):215        self.ra = ra216        self.rb = rb217        self.rc = rc218    def __repr__(self):219        return self.__str__()220    def __str__(self):221        return " ".join([INSTRUCTION.FLT, self.ra, self.rb , self.rc])222class LeqInstructionFloat(Instruction):223    def __init__(self, ra, rb, rc):224        self.ra = ra225        self.rb = rb226        self.rc = rc227    def __repr__(self):228        return self.__str__()229    def __str__(self):230        return " ".join([INSTRUCTION.FLEQ, self.ra, self.rb , self.rc])231class LtInstructionFloat(Instruction):232    def __init__(self, ra, rb, rc):233        self.ra = ra234        self.rb = rb235        self.rc = rc236    def __repr__(self):237        return self.__str__()238    def __str__(self):239        return " ".join([INSTRUCTION.FLT, self.ra, self.rb , self.rc])240######################################################################241######################################################################242class Itof_Instruction(Instruction):243    def __init__(self, ra, rb):244        self.ra = ra245        self.rb = rb246    def __repr__(self):247        return self.__str__()248    def __str__(self):249        return " ".join([INSTRUCTION.ITOF, self.ra, self.rb])250class Itoi_Instruction(Instruction):251    def __init__(self, ra, rb):252        self.ra = ra253        self.rb = rb254    def __repr__(self):255        return self.__str__()256    def __str__(self):257        return " ".join([INSTRUCTION.FTOI, self.ra, self.rb])258######################################################################259######################################################################260class HloadInstruction(Instruction):261    def __init__(self, ra, rb, rc):262        self.ra = ra263        self.rb = rb264        self.rc = rc265    def __repr__(self):266        return self.__str__()267    def __str__(self):268        return " ".join([INSTRUCTION.HLOAD, self.ra, self.rb , self.rc])269class HstoreInstruction(Instruction):270    def __init__(self, ra, rb, rc):271        self.ra = ra272        self.rb = rb273        self.rc = rc274    def __repr__(self):275        return self.__str__()276    def __str__(self):277        return " ".join([INSTRUCTION.HSTORE, self.ra, self.rb , self.rc])278class HallocInstruction(Instruction):279    def __init__(self, ra, rb):280        self.ra = ra281        self.rb = rb282    def __repr__(self):283        return self.__str__()284    def __str__(self):285        return " ".join([INSTRUCTION.HALLOC, self.ra, self.rb])286######################################################################287######################################################################288class Bz_Instruction(Instruction):289    def __init__(self, ra, rb):290        self.ra = ra291        self.rb = rb292    def __repr__(self):293        return self.__str__()294    def __str__(self):295        return " ".join([INSTRUCTION.BZ, self.ra, self.rb])296class Bnz_Instruction(Instruction):297    def __init__(self, ra, rb):298        self.ra = ra299        self.rb = rb300    def __repr__(self):301        return self.__str__()302    def __str__(self):303        return " ".join([INSTRUCTION.BNZ, self.ra, self.rb])304class Jmp_Instruction(Instruction):305    def __init__(self, ra):306        self.ra = ra307    def __repr__(self):308        return self.__str__()309    def __str__(self):310        return " ".join([INSTRUCTION.JMP, self.ra])311######################################################################312######################################################################313class Call_Instruction(Instruction):314    def __init__(self, ra):315        self.ra = ra316    def __repr__(self):317        return self.__str__()318    def __str__(self):319        return " ".join([INSTRUCTION.CALL, self.ra])320class Ret_Instruction(Instruction):321    def __init__(self): pass322    def __repr__(self):323        return self.__str__()324    def __str__(self):325        return " ".join([INSTRUCTION.RET])326class Save_Instruction(Instruction):327    def __init__(self, ra):328        self.ra = ra329    def __repr__(self):330        return self.__str__()331    def __str__(self):332        return " ".join([INSTRUCTION.SAVE, self.ra])333class Restore_Instruction(Instruction):334    def __init__(self, ra):335        self.ra = ra336    def __repr__(self):337        return self.__str__()338    def __str__(self):339        return " ".join([INSTRUCTION.RESTORE, self.ra])340class Peek_Instruction(Instruction):341    def __init__(self, ra):342        self.ra = ra343    def __repr__(self):344        return self.__str__()345    def __str__(self):346        return " ".join([INSTRUCTION.PEEK, self.ra])347class Nop_Instruction(Instruction):348    def __init__(self, ra):349        self.ra = ra350    def __repr__(self):351        return self.__str__()352    def __str__(self):353        return " ".join([INSTRUCTION.NOP, self.ra])354######################################################################355######################################################################356class INSTRUCTION(object):357    instList =  [ 'move_immed_i',358                  'move_immed_f',359                  'move',360                  'iadd',361                  'isub',362                  'imul',363                  'idiv',364                  'imod',365                  'igt',366                  'igeq',...start.py
Source:start.py  
...1920# # test __eq__21# card1Copy = Card.Card(3, 'S', False)22# if (card1 == card1Copy):23# 	print (card1.__str__() + " and " + card1Copy.__str__() + " are equal")24# else:25# 	print (card1.__str__() + " and " + card1Copy.__str__() + " are not equal")26# card2 = Card.Card(4, 'S', False)27# if (card1 == card2):28# 	print (card1.__str__() + " and " + card2.__str__() + " are equal")29# else:30# 	print (card1.__str__() + " and " + card2.__str__() + " are not equal")3132# # test __lt__33# if (card1 < card1Copy):34# 	print (card1.__str__() + " < " + card1Copy.__str__())35# else:36# 	print (card1.__str__() + " !< " + card1Copy.__str__())3738# if (card1 < card2):39# 	print (card1.__str__() + " < " + card2.__str__())40# else:41# 	print (card1.__str__() + " !< " + card2.__str__())4243# if (card1 > card2):44# 	print (card1.__str__() + " > " + card2.__str__())45# else:46# 	print (card1.__str__() + " !> " + card2.__str__())4748# # test __gt__ (not yet created)49# card3 = Card.Card(10, 'K', False)50# card4 = Card.Card(10, 'C', False)51# card5 = Card.Card(9, 'K', False)52# if (card3 > card4):53# 	print (card3.__str__() + " > " + card4.__str__())54# else:55# 	print (card3.__str__() + " !> " + card4.__str__())5657# if (card3 > card5):58# 	print (card3.__str__() + " > " + card5.__str__())59# else:60# 	print (card3.__str__() + " !> " + card5.__str__())6162# # test X J Q K63# print(Card.Card(10, 'T', False))64# print(Card.Card(11, 'T', False))65# print(Card.Card(12, 'T', False))66# print(Card.Card(13, 'T', False))6768# # test wildcard69# if (card1.isWildcard()):70# 	print(card1.__str__() + " is wild")71# else:72# 	print(card1.__str__() + " is not wild")73	74# wild = Card.Card(13, 'T', True)75# if (wild.isWildcard()):76# 	print(wild.__str__() + " is wild")77# else:78# 	print(wild.__str__() + " is not wild")7980# # test joker81# if (card1.isJoker()):82# 	print(card1.__str__() + " is s joker")83# else:84# 	print(card1.__str__() + " is not joker")85	86# joker = Card.Card(11, '1', False)87# if (joker.isJoker()):88# 	print(joker.__str__() + " is joker")89# else:90# 	print(joker.__str__() + " is not joker")91# notJoker = Card.Card(11, 'S', False)92# if (notJoker.isJoker()):93# 	print(notJoker.__str__() + " is joker")94# else:95# 	print(notJoker.__str__() + " is not joker")9697###############################################9899# test Deck100# deck = Deck.Deck()101# print(deck)102103# # test shuffle104# deck.shuffle()105# print(deck)106107# test deal card108# decktoDeal = Deck.Deck()109# print(decktoDeal)110111# topCard = decktoDeal.dealCard()112# print("Top card: " + topCard.__str__())113# print(decktoDeal)114115###############################################116# test CardDealer117# dealer = CardDealer.CardDealer()118# # print(dealer)119120# # test dealCard121# nextCard = dealer.dealCard()122123# drawPile = [nextCard, ]124# while (nextCard.getFace() != 0 and nextCard.getSuit() != '0'):125# 	drawPile.insert(0, nextCard)126# 	nextCard = dealer.dealCard()127128# print("Draw pile: " + drawPile.__str__())129130#######################################131# # test Player132# player = Player.Player()133# # print(player)134135# # assign 5 cards to Player136# deck = Deck.Deck()137# for i in range(0, 5):138# 	player.addCard(deck.dealTopCard())139# print(player)140141# # test getPointsInHand142# print(player.getPointsInHand())143144# # test clearHand145# player.clearHand()146# print(player)147148########################################149# test round150# roundNum = 1151# human = Player.Player(0, [])152# # print(hex(id(human)))153# computer = Player.Player(0, [])154# # print(hex(id(computer)))155156# round = Round.Round(roundNum, True, human, computer)157158# # print(round)159160# # test load161# #round.fileToRound("C:\\Users\\kdawg\\Desktop\\Ramapo\\OPL\\5_Crowns_python\\serial\\case1.txt")162163# # test save164# # round.save("C:\\Users\\kdawg\\Desktop\\Ramapo\\OPL\\5_Crowns_python\\serial\\test.txt")165166# # test Game167# game = Game.Game()168# # print(game)169170# # test load171# # game.load()172173# # test play174# game.startGame()175176# # test moveComputer177# print("Moving computer...")178# game.moveComputer()179# print(game.__str__())180181# # test humanDrawCard182# print("Human is drawing card...")183# game.humanDrawCard(1)184# print(game)185186# # test humanDiscardCard187# print("Human is discarding card...")188# game.humanDiscardCard(2)189# print(game)190191192# test Assembler sort by hand193# hand = []194# hand.append(Card.Card(5, 'D', False))195# hand.append(Card.Card(5, 'T', False))196# hand.append(Card.Card(11, '3', False))197# hand.append(Card.Card(11, '1', False))198# hand.append(Card.Card(3, 'S', False))199# hand.append(Card.Card(5, 'S', False))200# hand.append(Card.Card(11, 'S', False))201# hand.append(Card.Card(4, 'S', False))202# print("original hand: ")203# print(*hand)204# print()205206# assembler = Assembler.Assembler()207208# test sort by face209# sorted = assembler.sortHandByFace(hand)210# print("sorted by face: ")211# print(*sorted)212# print()213214# # test sort by suit215# print("sorted by suit: ")216# sorted = assembler.sortHandBySuit(hand)217# print(*sorted)218# print()219220# test isBook221# hand = []222# hand.append(Card.Card(11, 'S', False))223# hand.append(Card.Card(4, 'D', False))224# hand.append(Card.Card(4, 'S', False))225# print(*hand)226# print(assembler.isBook(hand))227# print() 228229# hand = []230# hand.append(Card.Card(4, 'S', False))231# hand.append(Card.Card(4, 'D', False))232# hand.append(Card.Card(4, 'S', False))233# print(*hand)234# print(assembler.isBook(hand))235# print()236237238# hand.append(Card.Card(11, '1', False))239# print(*hand)240# print(assembler.isBook(hand))241# print()242243# test isRun244assembler = Assembler.Assembler()245246# hand = []247# hand.append(Card.Card(4, 'S', False))248# hand.append(Card.Card(4, 'D', False))249# hand.append(Card.Card(4, 'S', False))250# print(*hand)251# print(assembler.isRun(hand))252# print()253254# hand.append(Card.Card(11, '1', False))255# print(*hand)256# print(assembler.isRun(hand))257# print()258259# hand.append(Card.Card(11, 'D', True))260# print(*hand)261# print(assembler.isRun(hand))262# print()263264# hand = []265# hand.append(Card.Card(3, 'S'))266# hand.append(Card.Card(4, 'S'))267# hand.append(Card.Card(4, 'S'))268# print(*hand)269# print(assembler.isRun(hand).__str__() + "\n")270271# del hand[2]272# hand.append(Card.Card(5, 'S'))273# print(*hand)274# print(assembler.isRun(hand).__str__() + "\n")275276# hand = []277# hand.append(Card.Card(4, 'S', True))278# hand.append(Card.Card(4, 'D'))279# hand.append(Card.Card(5, 'S'))280# print(*hand)281# print(assembler.isRun(hand))282# print()283284# """ test getAllBooks """285# hand = []286# hand.append(Card.Card(4, 'D'))287# hand.append(Card.Card(7, 'D'))288# hand.append(Card.Card(4, 'T'))289# hand.append(Card.Card(4, 'H'))290# hand.append(Card.Card(4, 'D'))291# hand.append(Card.Card(3, 'D'))292# hand.append(Card.Card(6, 'D'))293# hand.append(Card.Card(3, 'T'))294# hand.append(Card.Card(3, 'S'))295# print(*hand)296297# allAssemblies = assembler.getAllBooks(hand)298# for assembly in allAssemblies:299# 	print(*assembly)300# 	# for card in assembly:301# 	# 	print(card.__str__() + " ", end="")302# 	# print()303304305""" test getAllRuns """306# hand = []307# hand.append(Card.Card(4, 'D'))308# hand.append(Card.Card(5, 'D'))309# hand.append(Card.Card(6, 'D'))310# hand.append(Card.Card(9, 'T'))311# hand.append(Card.Card(10, 'T'))312# hand.append(Card.Card(11, 'T'))313# hand.append(Card.Card(12, 'T'))314# print(*hand)315# runs = assembler.getAllRuns(hand)316# for run in runs:317# 	print(*run)318319320""" test getAllAssemblies """321# hand = []322# hand.append(Card.Card(4, 'H'))323# hand.append(Card.Card(4, 'T'))324# hand.append(Card.Card(4, 'D'))325# hand.append(Card.Card(7, 'D'))326# hand.append(Card.Card(3, 'S'))327# hand.append(Card.Card(6, 'D'))328# hand.append(Card.Card(5, 'D'))329330331# hand.append(Card.Card(4, 'D'))332# hand.append(Card.Card(11, 'T'))333# hand.append(Card.Card(4, 'D'))334# hand.append(Card.Card(12, 'T'))335# hand.append(Card.Card(3, 'D'))336# hand.append(Card.Card(3, 'T'))337# # hand.append(Card.Card(5, 'D'))338# # hand.append(Card.Card(9, 'T'))339# # hand.append(Card.Card(6, 'D'))340# # hand.append(Card.Card(5, 'T'))341# # hand.append(Card.Card(10, 'T'))342# print(*hand)343# sorted = assembler.sortHandBySuit(hand)344# print (*sorted)345346# runs = assembler.getAllRuns(hand)347# print("runs:")348# for ass in runs:349# 	print(*ass)350351# asses = assembler.getAllAssemblies(hand)352# for ass in asses:353# 	print(*ass)354355356# print(assembler.__str__())357# tempAssembly = Assembler.Assembler(hand)358# print("trying to solve: " + tempAssembly.__str__())359# print()360361# allAssemblies = assembler.getAllAssemblies(hand)362363# print("all assemblies:")364# for ass in allAssemblies:365# 	print(*ass)366# 	for idk in ass:367# 		print(*idk)368# allAssemblies = assembler.getAllBooks(hand)369# for ass in allAssemblies:370# 	print(*ass)371372# # """ test getBestAssembly """373# print(assembler.getBestAssembly(Assembler.Assembler(hand), Assembler.Assembler()).__str__())374375# """ test getBestHand """376# print(*assembler.getBestHand(hand))377378# game = Game.Game()379# game.startGame()380381# # TODO this don't work382# hand = []383# hand.append(Card.Card(5, "T"))384# hand.append(Card.Card(7, "T"))385# hand.append(Card.Card(8, "T"))386# hand.append(Card.Card(4, "C", True))387388# print(Assembler.Assembler.isRun(hand))389390# game = Game.Game()391# game.load("C:\\Users\\kdawg\\Desktop\\Ramapo\\OPL\\5_Crowns_python\\serial\\case1.txt")392# game.play()393394# hand = []395# hand.append(Card.Card(3, "T", True))396# hand.append(Card.Card(6, "H"))397# hand.append(Card.Card(12, "S"))398# hand.append(Card.Card(11, "3"))399# print(*Assembler.Assembler.getBestHand(hand))400401# c = Controller.Controller()402# c.run()403404# test assembler405# hand = []406# hand.append(Card.Card(3, 'D', True))407# hand.append(Card.Card(9, 'D'))408# hand.append(Card.Card(5, 'H'))409# hand.append(Card.Card(7, 'T'))410# print("hand = ", end="")411# print(*hand)412413# print(Assembler.Assembler.getBestAssembly(Assembler.Assembler(hand), Assembler.Assembler()))414415# hand = []416# hand.append(Card.Card(5, 'T'))417# hand.append(Card.Card(4, 'S', True))418# hand.append(Card.Card(7, 'T'))419# hand.append(Card.Card(8, 'T'))420421# print(Assembler.Assembler.getBestAssembly(Assembler.Assembler(hand), Assembler.Assembler()).__str__())422423# print ("Hand: ", end="")424# print(*hand)425# print(Assembler.Assembler.isRun(hand).__str__())426427# draw = []428# draw.append(Card.Card(3, 'H', True))429# discard = []430# discard.append(Card.Card(6, 'D', True))431432# p1 = Player.Player(0, hand)433434# print("player: " + p1.__str__())435# print("draw: ", end="")436# print(*draw)437# print("discard: ", end="")438# print(*discard)439440# choice, reason = p1.helpDraw(draw, discard)441# print("choice: " + choice.__str__())442# print("reason: " + reason)443
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
