def test_this_call(self): assert ord('a') == +(pipe(ord) | this('a'))
def test_this_div(self): self.assertEqual(3, +(pipe(21) | this / 7)) self.assertEqual(3, +(pipe(7) | 21 / this))
def test_this_pow(self): assert 8 == +(pipe(2) | this ** 3) assert 8 == +(pipe(3) | 2 ** this)
def test_pipe_logical_expressions(self): self.assertEqual(0, +(pipe(1) | (this | 0) | (this & 0)))
def test_this_sub(self): self.assertEqual(7, +(pipe(21) | this - 14)) self.assertEqual(7, +(pipe(14) | 21 - this))
def test_base_behavior(self): self.assertEqual(5, +(pipe(3) | foo()))
def test_picle_unpickle(self): self.assertEqual(5, +(pipe(3) | pickle.loads(pickle.dumps(foo))()))
def test_this_mul(self): self.assertEqual(21, +(pipe(7) | this * 3)) self.assertEqual(21, +(pipe(7) | 3 * this))
def test_this_add(self): self.assertEqual(3, +(pipe(2) | this + 1)) self.assertEqual(3, +(pipe(2) | 1 + this))
def test_unbound_pipe(self): transform = pipe() | this * 2 | this + 4 self.assertEqual(8, +(pipe(2) | transform))
def test_this_getitem(self): assert 2 == +(pipe(dict(a=1, b=2)) | this['b'])
def test_this_floordir(self): assert 3 == +(pipe(24) | this // 7) assert 3 == +(pipe(7) | 24 // this)
def test_lit_call(self): assert ord('a') == +(pipe('a') | lit(ord)(this))
def test_this_pow(self): assert 8 == +(pipe(2) | this**3) assert 8 == +(pipe(3) | 2**this)
def test_this_abs(self): assert 1 == +(pipe(-1) | abs(this))
def test_this_attr_call(self): assert [1, 2, 3] == +(pipe(dict(a=1, b=2, c=3)) | this.values() | sorted)
def test_lit(self): assert 1 == +(pipe(2) | lit(1))
def test_pipe_callables(self): self.assertEqual(8, +(pipe(2) | (lambda x: x * 2) | (lambda x: x + 4)))
def test_pipe_this(self): self.assertEqual(8, +(pipe(2) | this * 2 | this + 4))