diff options
| author | Benjamin Peterson <benjamin@python.org> | 2014-04-09 23:55:56 -0400 |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2014-04-09 23:55:56 -0400 |
| commit | d51374ed78a3e3145911a16cdf3b9b84b3ba7d15 (patch) | |
| tree | 31f9086f20f5b8923604f41f1a4d139fa809aaed /Lib/test/test_grammar.py | |
| parent | 2aad6ef77419887f5875ba942e9369b4bdd34a5e (diff) | |
| download | cpython-git-d51374ed78a3e3145911a16cdf3b9b84b3ba7d15.tar.gz | |
PEP 465: a dedicated infix operator for matrix multiplication (closes #21176)
Diffstat (limited to 'Lib/test/test_grammar.py')
| -rw-r--r-- | Lib/test/test_grammar.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index bba8820ab1..a7bad2d2d9 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -985,6 +985,20 @@ class GrammarTests(unittest.TestCase): self.assertFalse((False is 2) is 3) self.assertFalse(False is 2 is 3) + def test_matrix_mul(self): + # This is not intended to be a comprehensive test, rather just to be few + # samples of the @ operator in test_grammar.py. + class M: + def __matmul__(self, o): + return 4 + def __imatmul__(self, o): + self.other = o + return self + m = M() + self.assertEqual(m @ m, 4) + m @= 42 + self.assertEqual(m.other, 42) + def test_main(): run_unittest(TokenTests, GrammarTests) |
