from metafunctions.util import node, star
from metafunctions.tests.util import BaseTestCase


class TestUnit(BaseTestCase):
    def test_simple_star(self):
        @node
        def f(*args):
            return args

        cmp = (a | b) | star(f)
        self.assertEqual(cmp('_'), ('_', 'a', 'b'))

    def test_str_repr(self):
        @node
        def f(*args):
            return args

        @star
        @node
        def g(*x):
            return x

        @node
        @star
        def h(*x):
            return x

        cmp = (a | b) | star(f)
        star_a = star(a)

        self.assertEqual(str(cmp), '(a | b | star(f))')
        self.assertEqual(str(star_a), 'star(a)')
        self.assertEqual(str(g), 'star(g)')
        self.assertEqual(str(h), 'h')

@node
def a(x):
    return x + 'a'
@node
def b(x):
    return x + 'b'

from metafunctions.util import node, star
from metafunctions.tests.util import BaseTestCase


class TestUnit(BaseTestCase):
    def test_simple_star(self):
        @node
        def f(*args):
            return args

        cmp = (a | b) | star(f)
        self.assertEqual(cmp('_'), ('_', 'a', 'b'))

    def test_str_repr(self):
        @node
        def f(*args):
            return args

        @star
        @node
        def g(*x):
            return x

        @node
        @star
        def h(*x):
            return x

        cmp = (a | b) | star(f)
        star_a = star(a)
        merge_star = star(a+b)
        chain_star = star(a|b)

        self.assertEqual(str(cmp), '(a | b | star(f))')
        self.assertEqual(str(star_a), 'star(a)')
        self.assertEqual(str(g), 'star(g)')
        self.assertEqual(str(h), 'h')
        self.assertEqual(str(merge_star), 'star(a + b)')
        self.assertEqual(str(h), 'star(a | b)')



@node
def a(x):
    return x + 'a'
@node
def b(x):
    return x + 'b'

Add more expected star str
Add more expected star str

  from metafunctions.util import node, star
  from metafunctions.tests.util import BaseTestCase
  
  
  class TestUnit(BaseTestCase):
      def test_simple_star(self):
          @node
          def f(*args):
              return args
  
          cmp = (a | b) | star(f)
          self.assertEqual(cmp('_'), ('_', 'a', 'b'))
  
      def test_str_repr(self):
          @node
          def f(*args):
              return args
  
          @star
          @node
          def g(*x):
              return x
  
          @node
          @star
          def h(*x):
              return x
  
          cmp = (a | b) | star(f)
          star_a = star(a)
+         merge_star = star(a+b)
+         chain_star = star(a|b)
  
          self.assertEqual(str(cmp), '(a | b | star(f))')
          self.assertEqual(str(star_a), 'star(a)')
          self.assertEqual(str(g), 'star(g)')
          self.assertEqual(str(h), 'h')
+         self.assertEqual(str(merge_star), 'star(a + b)')
+         self.assertEqual(str(h), 'star(a | b)')
+ 
+ 
  
  @node
  def a(x):
      return x + 'a'
  @node
  def b(x):
      return x + 'b'
  
Add more expected star str
## Code Before:
from metafunctions.util import node, star
from metafunctions.tests.util import BaseTestCase


class TestUnit(BaseTestCase):
    def test_simple_star(self):
        @node
        def f(*args):
            return args

        cmp = (a | b) | star(f)
        self.assertEqual(cmp('_'), ('_', 'a', 'b'))

    def test_str_repr(self):
        @node
        def f(*args):
            return args

        @star
        @node
        def g(*x):
            return x

        @node
        @star
        def h(*x):
            return x

        cmp = (a | b) | star(f)
        star_a = star(a)

        self.assertEqual(str(cmp), '(a | b | star(f))')
        self.assertEqual(str(star_a), 'star(a)')
        self.assertEqual(str(g), 'star(g)')
        self.assertEqual(str(h), 'h')

@node
def a(x):
    return x + 'a'
@node
def b(x):
    return x + 'b'

## Instruction:
Add more expected star str
## Code After:
from metafunctions.util import node, star
from metafunctions.tests.util import BaseTestCase


class TestUnit(BaseTestCase):
    def test_simple_star(self):
        @node
        def f(*args):
            return args

        cmp = (a | b) | star(f)
        self.assertEqual(cmp('_'), ('_', 'a', 'b'))

    def test_str_repr(self):
        @node
        def f(*args):
            return args

        @star
        @node
        def g(*x):
            return x

        @node
        @star
        def h(*x):
            return x

        cmp = (a | b) | star(f)
        star_a = star(a)
        merge_star = star(a+b)
        chain_star = star(a|b)

        self.assertEqual(str(cmp), '(a | b | star(f))')
        self.assertEqual(str(star_a), 'star(a)')
        self.assertEqual(str(g), 'star(g)')
        self.assertEqual(str(h), 'h')
        self.assertEqual(str(merge_star), 'star(a + b)')
        self.assertEqual(str(h), 'star(a | b)')



@node
def a(x):
    return x + 'a'
@node
def b(x):
    return x + 'b'
