From ab69ed7dac1bf0ef36238b6289d436e9932180bc Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 15 Mar 2016 13:07:41 +0000 Subject: [PATCH] tests: Split large tests into smaller files, to run with a small heap. All tests in basics/ directory can now run and pass using 64-bit unix port with only a 16k heap (./run-tests --heapsize 16k). Tests in this directory should remain small so they can be used for ports with a small heap. --- tests/basics/exceptpoly.py | 101 ------------------ tests/basics/exceptpoly2.py | 99 ++++++++++++++++++ tests/basics/int_big_and.py | 104 ------------------- tests/basics/int_big_and2.py | 51 ++++++++++ tests/basics/int_big_and3.py | 51 ++++++++++ tests/basics/int_big_or.py | 99 ------------------ tests/basics/int_big_or2.py | 50 +++++++++ tests/basics/int_big_or3.py | 51 ++++++++++ tests/basics/int_big_xor.py | 98 ------------------ tests/basics/int_big_xor2.py | 51 ++++++++++ tests/basics/int_big_xor3.py | 51 ++++++++++ tests/basics/string_format.py | 153 +--------------------------- tests/basics/string_format2.py | 64 ++++++++++++ tests/basics/string_format_error.py | 90 ++++++++++++++++ 14 files changed, 559 insertions(+), 554 deletions(-) create mode 100644 tests/basics/exceptpoly2.py create mode 100644 tests/basics/int_big_and2.py create mode 100644 tests/basics/int_big_and3.py create mode 100644 tests/basics/int_big_or2.py create mode 100644 tests/basics/int_big_or3.py create mode 100644 tests/basics/int_big_xor2.py create mode 100644 tests/basics/int_big_xor3.py create mode 100644 tests/basics/string_format2.py create mode 100644 tests/basics/string_format_error.py diff --git a/tests/basics/exceptpoly.py b/tests/basics/exceptpoly.py index bf463fbee1..9e210de80f 100644 --- a/tests/basics/exceptpoly.py +++ b/tests/basics/exceptpoly.py @@ -97,104 +97,3 @@ try: raise LookupError except LookupError: print("Caught LookupError") - -try: - raise MemoryError -except Exception: - print("Caught MemoryError via Exception") - -try: - raise MemoryError -except MemoryError: - print("Caught MemoryError") - -try: - raise NameError -except Exception: - print("Caught NameError via Exception") - -try: - raise NameError -except NameError: - print("Caught NameError") - -try: - raise NotImplementedError -except RuntimeError: - print("Caught NotImplementedError via RuntimeError") - -try: - raise NotImplementedError -except NotImplementedError: - print("Caught NotImplementedError") - -try: - raise OSError -except Exception: - print("Caught OSError via Exception") - -try: - raise OSError -except OSError: - print("Caught OSError") - -try: - raise OverflowError -except ArithmeticError: - print("Caught OverflowError via ArithmeticError") - -try: - raise OverflowError -except OverflowError: - print("Caught OverflowError") - -try: - raise RuntimeError -except Exception: - print("Caught RuntimeError via Exception") - -try: - raise RuntimeError -except RuntimeError: - print("Caught RuntimeError") - -try: - raise SyntaxError -except Exception: - print("Caught SyntaxError via Exception") - -try: - raise SyntaxError -except SyntaxError: - print("Caught SyntaxError") - -try: - raise TypeError -except Exception: - print("Caught TypeError via Exception") - -try: - raise TypeError -except TypeError: - print("Caught TypeError") - -try: - raise ValueError -except Exception: - print("Caught ValueError via Exception") - -try: - raise ValueError -except ValueError: - print("Caught ValueError") - -try: - raise ZeroDivisionError -except ArithmeticError: - print("Caught ZeroDivisionError via ArithmeticError") - -try: - raise ZeroDivisionError -except ZeroDivisionError: - print("Caught ZeroDivisionError") - diff --git a/tests/basics/exceptpoly2.py b/tests/basics/exceptpoly2.py new file mode 100644 index 0000000000..e75308d64b --- /dev/null +++ b/tests/basics/exceptpoly2.py @@ -0,0 +1,99 @@ +try: + raise MemoryError +except Exception: + print("Caught MemoryError via Exception") + +try: + raise MemoryError +except MemoryError: + print("Caught MemoryError") + +try: + raise NameError +except Exception: + print("Caught NameError via Exception") + +try: + raise NameError +except NameError: + print("Caught NameError") + +try: + raise NotImplementedError +except RuntimeError: + print("Caught NotImplementedError via RuntimeError") + +try: + raise NotImplementedError +except NotImplementedError: + print("Caught NotImplementedError") + +try: + raise OSError +except Exception: + print("Caught OSError via Exception") + +try: + raise OSError +except OSError: + print("Caught OSError") + +try: + raise OverflowError +except ArithmeticError: + print("Caught OverflowError via ArithmeticError") + +try: + raise OverflowError +except OverflowError: + print("Caught OverflowError") + +try: + raise RuntimeError +except Exception: + print("Caught RuntimeError via Exception") + +try: + raise RuntimeError +except RuntimeError: + print("Caught RuntimeError") + +try: + raise SyntaxError +except Exception: + print("Caught SyntaxError via Exception") + +try: + raise SyntaxError +except SyntaxError: + print("Caught SyntaxError") + +try: + raise TypeError +except Exception: + print("Caught TypeError via Exception") + +try: + raise TypeError +except TypeError: + print("Caught TypeError") + +try: + raise ValueError +except Exception: + print("Caught ValueError via Exception") + +try: + raise ValueError +except ValueError: + print("Caught ValueError") + +try: + raise ZeroDivisionError +except ArithmeticError: + print("Caught ZeroDivisionError via ArithmeticError") + +try: + raise ZeroDivisionError +except ZeroDivisionError: + print("Caught ZeroDivisionError") diff --git a/tests/basics/int_big_and.py b/tests/basics/int_big_and.py index b3bba37c19..062a4f22af 100644 --- a/tests/basics/int_big_and.py +++ b/tests/basics/int_big_and.py @@ -39,107 +39,3 @@ print((-a) & (-0xffffffffffffffffffffffffffffffff)) print((-1) & (-0xffffffffffffffffffffffffffffffff)) print((-a) & (-2)) print((-mpz) & (-2)) - -# test + + - -print( 97989513389222316022151446562729620153292831887555425160965597396 - & 23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - & 37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - & 98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - & 15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - & 63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - & 59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - & 86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - & 9487909752) - -# test - + - -print( -97989513389222316022151446562729620153292831887555425160965597396 - & 23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - & 37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - & 98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - & 15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - & 63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - & 59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - & 86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - & 9487909752) - -# test + - - -print( 97989513389222316022151446562729620153292831887555425160965597396 - & -23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - & -37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - & -98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - & -15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - & -63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - & -59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - & -86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - & -9487909752) - -# test - - - -print( -97989513389222316022151446562729620153292831887555425160965597396 - & -23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - & -37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - & -98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - & -15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - & -63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - & -59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - & -86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - & -9487909752) diff --git a/tests/basics/int_big_and2.py b/tests/basics/int_big_and2.py new file mode 100644 index 0000000000..f8c81fe0cd --- /dev/null +++ b/tests/basics/int_big_and2.py @@ -0,0 +1,51 @@ +# test + + + +print( 97989513389222316022151446562729620153292831887555425160965597396 + & 23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + & 37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + & 98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + & 15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + & 63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + & 59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + & 86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + & 9487909752) + +# test - - + +print( -97989513389222316022151446562729620153292831887555425160965597396 + & -23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + & -37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + & -98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + & -15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + & -63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + & -59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + & -86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + & -9487909752) diff --git a/tests/basics/int_big_and3.py b/tests/basics/int_big_and3.py new file mode 100644 index 0000000000..788ecd823b --- /dev/null +++ b/tests/basics/int_big_and3.py @@ -0,0 +1,51 @@ +# test - + + +print( -97989513389222316022151446562729620153292831887555425160965597396 + & 23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + & 37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + & 98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + & 15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + & 63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + & 59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + & 86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + & 9487909752) + +# test + - + +print( 97989513389222316022151446562729620153292831887555425160965597396 + & -23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + & -37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + & -98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + & -15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + & -63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + & -59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + & -86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + & -9487909752) diff --git a/tests/basics/int_big_or.py b/tests/basics/int_big_or.py index 0defd984e2..17d9935265 100644 --- a/tests/basics/int_big_or.py +++ b/tests/basics/int_big_or.py @@ -3,7 +3,6 @@ print(0 | (1 << 80)) a = 0xfffffffffffffffffffffffffffff print(a | (1 << 200)) - # test + + print(0 | (1 << 80)) @@ -16,30 +15,6 @@ print(a | (1 << 200)) print(a | a == 0) print(bool(a | a)) -print( 97989513389222316022151446562729620153292831887555425160965597396 - | 23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - | 37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - | 98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - | 15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - | 63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - | 59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - | 86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - | 9487909752) - # test - + print((-1 << 80) | (1 << 80)) @@ -50,30 +25,6 @@ print((-a) | (1 << 200)) print((-a) | a == 0) print(bool((-a) | a)) -print( -97989513389222316022151446562729620153292831887555425160965597396 - | 23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - | 37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - | 98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - | 15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - | 63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - | 59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - | 86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - | 9487909752) - # test + - print(0 | (-1 << 80)) @@ -84,30 +35,6 @@ print(a | (-1 << 200)) print(a | (-a) == 0) print(bool(a | (-a))) -print( 97989513389222316022151446562729620153292831887555425160965597396 - | -23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - | -37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - | -98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - | -15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - | -63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - | -59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - | -86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - | -9487909752) - # test - - print((-1 << 80) | (-1 << 80)) @@ -116,29 +43,3 @@ print((-a) | (-1 << 100)) print((-a) | (-1 << 200)) print((-a) | (-a) == 0) print(bool((-a) | (-a))) - -print( -97989513389222316022151446562729620153292831887555425160965597396 - | -23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - | -37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - | -98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - | -15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - | -63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - | -59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - | -86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - | -9487909752) - - diff --git a/tests/basics/int_big_or2.py b/tests/basics/int_big_or2.py new file mode 100644 index 0000000000..255495150a --- /dev/null +++ b/tests/basics/int_big_or2.py @@ -0,0 +1,50 @@ +# test + + +print( 97989513389222316022151446562729620153292831887555425160965597396 + | 23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + | 37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + | 98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + | 15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + | 63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + | 59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + | 86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + | 9487909752) + +# test - - + +print( -97989513389222316022151446562729620153292831887555425160965597396 + | -23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + | -37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + | -98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + | -15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + | -63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + | -59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + | -86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + | -9487909752) diff --git a/tests/basics/int_big_or3.py b/tests/basics/int_big_or3.py new file mode 100644 index 0000000000..07edaea2df --- /dev/null +++ b/tests/basics/int_big_or3.py @@ -0,0 +1,51 @@ +# test - + + +print( -97989513389222316022151446562729620153292831887555425160965597396 + | 23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + | 37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + | 98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + | 15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + | 63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + | 59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + | 86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + | 9487909752) + +# test + - + +print( 97989513389222316022151446562729620153292831887555425160965597396 + | -23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + | -37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + | -98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + | -15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + | -63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + | -59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + | -86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + | -9487909752) diff --git a/tests/basics/int_big_xor.py b/tests/basics/int_big_xor.py index f14a763a4d..943d1ac15d 100644 --- a/tests/basics/int_big_xor.py +++ b/tests/basics/int_big_xor.py @@ -1,4 +1,3 @@ - # test + + print(0 ^ (1 << 80)) @@ -11,30 +10,6 @@ print(a ^ (1 << 200)) print(a ^ a == 0) print(bool(a ^ a)) -print( 97989513389222316022151446562729620153292831887555425160965597396 - ^ 23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - ^ 37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - ^ 98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - ^ 15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - ^ 63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - ^ 59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - ^ 86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - ^ 9487909752) - # test - + print((-1 << 80) ^ (1 << 80)) @@ -45,30 +20,6 @@ print((-a) ^ (1 << 200)) print((-a) ^ a == 0) print(bool((-a) ^ a)) -print( -97989513389222316022151446562729620153292831887555425160965597396 - ^ 23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - ^ 37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - ^ 98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - ^ 15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - ^ 63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - ^ 59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - ^ 86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - ^ 9487909752) - # test + - print(0 ^ (-1 << 80)) @@ -79,30 +30,6 @@ print(a ^ (-1 << 200)) print(a ^ (-a) == 0) print(bool(a ^ (-a))) -print( 97989513389222316022151446562729620153292831887555425160965597396 - ^ -23716683549865351578586448630079789776107310103486834795830390982) - -print( 53817081128841898634258263553430908085326601592682411889506742059 - ^ -37042558948907407488299113387826240429667200950043601129661240876) - -print( 26167512042587370698808974207700979337713004510730289760097826496 - ^ -98456276326770292376138852628141531773120376436197321310863125849) - -print( 21085380307304977067262070503651827226504797285572981274069266136 - ^ -15928222825828272388778130358888206480162413547887287646273147570) - -print( 40827393422334167255488276244226338235131323044408420081160772273 - ^ -63815443187857978125545555033672525708399848575557475462799643340) - -print( 5181013159871685724135944379095645225188360725917119022722046448 - ^ -59734090450462480092384049604830976376887859531148103803093112493) - -print( 283894311 - ^ -86526825689187217371383854139783231460931720533100376593106943447) - -print( 40019818573920230246248826511203818792007462193311949166285967147 - ^ -9487909752) - # test - - print((-1 << 80) ^ (-1 << 80)) @@ -111,28 +38,3 @@ print((-a) ^ (-1 << 100)) print((-a) ^ (-1 << 200)) print((-a) ^ (-a) == 0) print(bool((-a) ^ (-a))) - -print( -97989513389222316022151446562729620153292831887555425160965597396 - ^ -23716683549865351578586448630079789776107310103486834795830390982) - -print( -53817081128841898634258263553430908085326601592682411889506742059 - ^ -37042558948907407488299113387826240429667200950043601129661240876) - -print( -26167512042587370698808974207700979337713004510730289760097826496 - ^ -98456276326770292376138852628141531773120376436197321310863125849) - -print( -21085380307304977067262070503651827226504797285572981274069266136 - ^ -15928222825828272388778130358888206480162413547887287646273147570) - -print( -40827393422334167255488276244226338235131323044408420081160772273 - ^ -63815443187857978125545555033672525708399848575557475462799643340) - -print( -5181013159871685724135944379095645225188360725917119022722046448 - ^ -59734090450462480092384049604830976376887859531148103803093112493) - -print( -283894311 - ^ -86526825689187217371383854139783231460931720533100376593106943447) - -print( -40019818573920230246248826511203818792007462193311949166285967147 - ^ -9487909752) - diff --git a/tests/basics/int_big_xor2.py b/tests/basics/int_big_xor2.py new file mode 100644 index 0000000000..b5b3db60c6 --- /dev/null +++ b/tests/basics/int_big_xor2.py @@ -0,0 +1,51 @@ +# test + + + +print( 97989513389222316022151446562729620153292831887555425160965597396 + ^ 23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + ^ 37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + ^ 98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + ^ 15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + ^ 63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + ^ 59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + ^ 86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + ^ 9487909752) + +# test - - + +print( -97989513389222316022151446562729620153292831887555425160965597396 + ^ -23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + ^ -37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + ^ -98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + ^ -15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + ^ -63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + ^ -59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + ^ -86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + ^ -9487909752) diff --git a/tests/basics/int_big_xor3.py b/tests/basics/int_big_xor3.py new file mode 100644 index 0000000000..00881e3740 --- /dev/null +++ b/tests/basics/int_big_xor3.py @@ -0,0 +1,51 @@ +# test - + + +print( -97989513389222316022151446562729620153292831887555425160965597396 + ^ 23716683549865351578586448630079789776107310103486834795830390982) + +print( -53817081128841898634258263553430908085326601592682411889506742059 + ^ 37042558948907407488299113387826240429667200950043601129661240876) + +print( -26167512042587370698808974207700979337713004510730289760097826496 + ^ 98456276326770292376138852628141531773120376436197321310863125849) + +print( -21085380307304977067262070503651827226504797285572981274069266136 + ^ 15928222825828272388778130358888206480162413547887287646273147570) + +print( -40827393422334167255488276244226338235131323044408420081160772273 + ^ 63815443187857978125545555033672525708399848575557475462799643340) + +print( -5181013159871685724135944379095645225188360725917119022722046448 + ^ 59734090450462480092384049604830976376887859531148103803093112493) + +print( -283894311 + ^ 86526825689187217371383854139783231460931720533100376593106943447) + +print( -40019818573920230246248826511203818792007462193311949166285967147 + ^ 9487909752) + +# test + - + +print( 97989513389222316022151446562729620153292831887555425160965597396 + ^ -23716683549865351578586448630079789776107310103486834795830390982) + +print( 53817081128841898634258263553430908085326601592682411889506742059 + ^ -37042558948907407488299113387826240429667200950043601129661240876) + +print( 26167512042587370698808974207700979337713004510730289760097826496 + ^ -98456276326770292376138852628141531773120376436197321310863125849) + +print( 21085380307304977067262070503651827226504797285572981274069266136 + ^ -15928222825828272388778130358888206480162413547887287646273147570) + +print( 40827393422334167255488276244226338235131323044408420081160772273 + ^ -63815443187857978125545555033672525708399848575557475462799643340) + +print( 5181013159871685724135944379095645225188360725917119022722046448 + ^ -59734090450462480092384049604830976376887859531148103803093112493) + +print( 283894311 + ^ -86526825689187217371383854139783231460931720533100376593106943447) + +print( 40019818573920230246248826511203818792007462193311949166285967147 + ^ -9487909752) diff --git a/tests/basics/string_format.py b/tests/basics/string_format.py index e07f0d9533..8b25924067 100644 --- a/tests/basics/string_format.py +++ b/tests/basics/string_format.py @@ -1,7 +1,4 @@ -# Change the following to True to get a much more comprehensive set of tests -# to run, albeit, which take considerably longer. - -full_tests = False +# basic functionality test for {} format string def test(fmt, *args): print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<') @@ -77,151 +74,3 @@ print("{text:{align}{width}}".format(text="foo", align=">", width=30)) print("{foo}/foo".format(foo="bar")) print("{}".format(123, foo="bar")) print("{}-{foo}".format(123, foo="bar")) - -def test_fmt(conv, fill, alignment, sign, prefix, width, precision, type, arg): - fmt = '{' - if conv: - fmt += '!' - fmt += conv - fmt += ':' - if alignment: - fmt += fill - fmt += alignment - fmt += sign - fmt += prefix - fmt += width - if precision: - fmt += '.' - fmt += precision - fmt += type - fmt += '}' - test(fmt, arg) - if fill == '0' and alignment == '=': - fmt = '{:' - fmt += sign - fmt += prefix - fmt += width - if precision: - fmt += '.' - fmt += precision - fmt += type - fmt += '}' - test(fmt, arg) - -int_nums = (-1234, -123, -12, -1, 0, 1, 12, 123, 1234, True, False) -int_nums2 = (-12, -1, 0, 1, 12, True, False) - -if full_tests: - for type in ('', 'b', 'd', 'o', 'x', 'X'): - for width in ('', '1', '3', '5', '7'): - for alignment in ('', '<', '>', '=', '^'): - for fill in ('', ' ', '0', '@'): - for sign in ('', '+', '-', ' '): - for prefix in ('', '#'): - for num in int_nums: - test_fmt('', fill, alignment, sign, prefix, width, '', type, num) - -if full_tests: - for width in ('', '1', '2'): - for alignment in ('', '<', '>', '^'): - for fill in ('', ' ', '0', '@'): - test_fmt('', fill, alignment, '', '', width, '', 'c', 48) - -if full_tests: - for conv in ('', 'r', 's'): - for width in ('', '1', '4', '10'): - for alignment in ('', '<', '>', '^'): - for fill in ('', ' ', '0', '@'): - for str in ('', 'a', 'bcd', 'This is a test with a longer string'): - test_fmt(conv, fill, alignment, '', '', width, '', 's', str) - -# tests for errors in format string - -try: - '{0:0}'.format('zzz') -except (ValueError): - print('ValueError') - -try: - '{1:}'.format(1) -except IndexError: - print('IndexError') - -try: - '}'.format('zzzz') -except ValueError: - print('ValueError') - -# end of format parsing conversion specifier -try: - '{!'.format('a') -except ValueError: - print('ValueError') - -# unknown conversion specifier -try: - 'abc{!d}'.format('1') -except ValueError: - print('ValueError') - -try: - '{abc'.format('zzzz') -except ValueError: - print('ValueError') - -# expected ':' after specifier -try: - '{!s :}'.format(2) -except ValueError: - print('ValueError') - -try: - '{}{0}'.format(1, 2) -except ValueError: - print('ValueError') - -try: - '{1:}'.format(1) -except IndexError: - print('IndexError') - -try: - '{ 0 :*^10}'.format(12) -except KeyError: - print('KeyError') - -try: - '{0}{}'.format(1) -except ValueError: - print('ValueError') - -try: - '{}{}'.format(1) -except IndexError: - print('IndexError') - -try: - '{0:+s}'.format('1') -except ValueError: - print('ValueError') - -try: - '{0:+c}'.format(1) -except ValueError: - print('ValueError') - -try: - '{0:s}'.format(1) -except ValueError: - print('ValueError') - -try: - '{:*"1"}'.format('zz') -except ValueError: - print('ValueError') - -# unknown format code for str arg -try: - '{:X}'.format('zz') -except ValueError: - print('ValueError') diff --git a/tests/basics/string_format2.py b/tests/basics/string_format2.py new file mode 100644 index 0000000000..e211535be4 --- /dev/null +++ b/tests/basics/string_format2.py @@ -0,0 +1,64 @@ +# comprehensive functionality test for {} format string + +int_tests = False # these take a while, and some give wrong results +char_tests = True +str_tests = True + +def test(fmt, *args): + print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<') + +def test_fmt(conv, fill, alignment, sign, prefix, width, precision, type, arg): + fmt = '{' + if conv: + fmt += '!' + fmt += conv + fmt += ':' + if alignment: + fmt += fill + fmt += alignment + fmt += sign + fmt += prefix + fmt += width + if precision: + fmt += '.' + fmt += precision + fmt += type + fmt += '}' + test(fmt, arg) + if fill == '0' and alignment == '=': + fmt = '{:' + fmt += sign + fmt += prefix + fmt += width + if precision: + fmt += '.' + fmt += precision + fmt += type + fmt += '}' + test(fmt, arg) + +if int_tests: + int_nums = (-1234, -123, -12, -1, 0, 1, 12, 123, 1234, True, False) + #int_nums = (-12, -1, 0, 1, 12, True, False) + for type in ('', 'b', 'd', 'o', 'x', 'X'): + for width in ('', '1', '3', '5', '7'): + for alignment in ('', '<', '>', '=', '^'): + for fill in ('', ' ', '0', '@'): + for sign in ('', '+', '-', ' '): + for prefix in ('', '#'): + for num in int_nums: + test_fmt('', fill, alignment, sign, prefix, width, '', type, num) + +if char_tests: + for width in ('', '1', '2'): + for alignment in ('', '<', '>', '^'): + for fill in ('', ' ', '0', '@'): + test_fmt('', fill, alignment, '', '', width, '', 'c', 48) + +if str_tests: + for conv in ('', 'r', 's'): + for width in ('', '1', '4', '10'): + for alignment in ('', '<', '>', '^'): + for fill in ('', ' ', '0', '@'): + for str in ('', 'a', 'bcd', 'This is a test with a longer string'): + test_fmt(conv, fill, alignment, '', '', width, '', 's', str) diff --git a/tests/basics/string_format_error.py b/tests/basics/string_format_error.py new file mode 100644 index 0000000000..708348d59f --- /dev/null +++ b/tests/basics/string_format_error.py @@ -0,0 +1,90 @@ +# tests for errors in {} format string + +try: + '{0:0}'.format('zzz') +except (ValueError): + print('ValueError') + +try: + '{1:}'.format(1) +except IndexError: + print('IndexError') + +try: + '}'.format('zzzz') +except ValueError: + print('ValueError') + +# end of format parsing conversion specifier +try: + '{!'.format('a') +except ValueError: + print('ValueError') + +# unknown conversion specifier +try: + 'abc{!d}'.format('1') +except ValueError: + print('ValueError') + +try: + '{abc'.format('zzzz') +except ValueError: + print('ValueError') + +# expected ':' after specifier +try: + '{!s :}'.format(2) +except ValueError: + print('ValueError') + +try: + '{}{0}'.format(1, 2) +except ValueError: + print('ValueError') + +try: + '{1:}'.format(1) +except IndexError: + print('IndexError') + +try: + '{ 0 :*^10}'.format(12) +except KeyError: + print('KeyError') + +try: + '{0}{}'.format(1) +except ValueError: + print('ValueError') + +try: + '{}{}'.format(1) +except IndexError: + print('IndexError') + +try: + '{0:+s}'.format('1') +except ValueError: + print('ValueError') + +try: + '{0:+c}'.format(1) +except ValueError: + print('ValueError') + +try: + '{0:s}'.format(1) +except ValueError: + print('ValueError') + +try: + '{:*"1"}'.format('zz') +except ValueError: + print('ValueError') + +# unknown format code for str arg +try: + '{:X}'.format('zz') +except ValueError: + print('ValueError')