def test_circular_eval_eval_error(self):
        env = ninja.EvalEnv()
        env['a'] = ninja.EvalStringBuilder().append_var('b').getvalue()
        env['b'] = ninja.EvalStringBuilder().append_var('b').getvalue()

        s = ninja.EvalStringBuilder().append_var('a').getvalue()
        with self.assertRaises(ninja.EvalCircularError):
            ninja.eval_string(s, env)
    def test_append_raw_concat(self):
        sb = ninja.EvalStringBuilder()
        sb.append_raw('a')
        sb.append_raw('b')
        s = sb.getvalue()

        self.assertTrue(s)
        self.assertEqual('ab', ninja.eval_string(s, ninja.EvalEnv()))
    def test_var_concat_eval(self):
        env = ninja.EvalEnv()
        env['key1'] = ninja.EvalStringBuilder().append_raw('a').getvalue()
        env['key2'] = ninja.EvalStringBuilder().append_raw('b').getvalue()

        sb = ninja.EvalStringBuilder()
        sb.append_var('key1')
        sb.append_var('key2')
        s = sb.getvalue()

        self.assertEqual('ab', ninja.eval_string(s, env))
    def test_raw_and_var_eval(self):
        env = ninja.EvalEnv()
        env['b'] = ninja.EvalStringBuilder().append_raw('d').getvalue()

        sb = ninja.EvalStringBuilder()
        sb.append_raw('a')
        sb.append_var('b')
        sb.append_raw('c')
        s = sb.getvalue()

        self.assertEqual('adc', ninja.eval_string(s, env))
 def test_unknown_variable_eval_error(self):
     s = ninja.EvalStringBuilder().append_var('a').getvalue()
     self.assertEqual('', ninja.eval_string(s, ninja.EvalEnv()))
    def test_var_eval(self):
        env = ninja.EvalEnv()
        env['key'] = ninja.EvalStringBuilder().append_raw('value').getvalue()

        s = ninja.EvalStringBuilder().append_var('key').getvalue()
        self.assertEqual('value', ninja.eval_string(s, env))
 def test_append_raw(self):
     s = ninja.EvalStringBuilder().append_raw('a').getvalue()
     self.assertTrue(s)
     self.assertEqual('a', ninja.eval_string(s, ninja.EvalEnv()))
 def test_empty(self):
     s = ninja.EvalStringBuilder().getvalue()
     self.assertFalse(s)
     self.assertEqual('', ninja.eval_string(s, ninja.EvalEnv()))