def test_expansion_simple(self):
        e = Expansion()
        e.appendstr('foo')
        e.appendstr('bar')

        v = VariableRef(None, e)

        self.assertEqual(v.to_source(), '$(foobar)')
    def test_basename(self):
        e1 = StringExpansion('foo', None)
        v = VariableRef(None, e1)
        e2 = Expansion(None)
        e2.appendfunc(v)

        b = BasenameFunction(None)
        b.append(e2)

        self.assertEqual(b.to_source(), '$(basename $(foo))')
    def test_curly_brackets(self):
        e1 = Expansion(None)
        e1.appendstr('foo')

        e2 = Expansion(None)
        e2.appendstr('foo ( bar')

        f = WordlistFunction(None)
        f.append(e1)
        f.append(e2)

        self.assertEqual(f.to_source(), '${wordlist foo,foo ( bar}')
    def test_string_escape(self):
        e = Expansion()
        e.appendstr('$var')
        self.assertEqual(e.to_source(), '$var')
        self.assertEqual(e.to_source(escape_variables=True), '$$var')

        e = Expansion()
        e.appendstr('foo')
        e.appendstr(' $bar')
        self.assertEqual(e.to_source(escape_variables=True), 'foo $$bar')
    def test_multiple_strings(self):
        e = Expansion()
        e.appendstr('hello')
        e.appendstr('world')

        self.assertEqual(e.to_source(), 'helloworld')
    def test_single_string(self):
        e = Expansion()
        e.appendstr('foo')

        self.assertEqual(e.to_source(), 'foo')