Bug 449749 nsWindowWatcher.cpp failed to compile with Sun Studio 12 r+sr=roc
[wine-gecko.git] / config / tests / unit-Expression.py
blobcb725448fa9bf1c25454e92b615ca4f9ee7a36e7
1 import unittest
3 import sys
4 import os.path
5 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
7 from Expression import Expression, Context
9 class TestContext(unittest.TestCase):
10 """
11 Unit tests for the Context class
12 """
14 def setUp(self):
15 self.c = Context()
16 self.c['FAIL'] = 'PASS'
18 def test_string_literal(self):
19 """test string literal, fall-through for undefined var in a Context"""
20 self.assertEqual(self.c['PASS'], 'PASS')
22 def test_variable(self):
23 """test value for defined var in the Context class"""
24 self.assertEqual(self.c['FAIL'], 'PASS')
26 def test_in(self):
27 """test 'var in context' to not fall for fallback"""
28 self.assert_('FAIL' in self.c)
29 self.assert_('PASS' not in self.c)
31 class TestExpression(unittest.TestCase):
32 """
33 Unit tests for the Expression class
34 evaluate() is called with a context {FAIL: 'PASS'}
35 """
37 def setUp(self):
38 self.c = Context()
39 self.c['FAIL'] = 'PASS'
41 def test_string_literal(self):
42 """Test for a string literal in an Expression"""
43 self.assertEqual(Expression('PASS').evaluate(self.c), 'PASS')
45 def test_variable(self):
46 """Test for variable value in an Expression"""
47 self.assertEqual(Expression('FAIL').evaluate(self.c), 'PASS')
49 def test_not(self):
50 """Test for the ! operator"""
51 self.assert_(Expression('!0').evaluate(self.c))
52 self.assert_(not Expression('!1').evaluate(self.c))
54 def test_equals(self):
55 """ Test for the == operator"""
56 self.assert_(Expression('FAIL == PASS').evaluate(self.c))
58 def test_notequals(self):
59 """ Test for the != operator"""
60 self.assert_(Expression('FAIL != 1').evaluate(self.c))
62 if __name__ == '__main__':
63 unittest.main()