Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: third_party/manifestdestiny/tests/test_expressionparser.py

Issue 108313011: Adding mozilla libraries required by Firefox interop test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/manifestdestiny/tests/test_expressionparser.py
===================================================================
--- third_party/manifestdestiny/tests/test_expressionparser.py (revision 0)
+++ third_party/manifestdestiny/tests/test_expressionparser.py (revision 0)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+import unittest
+from manifestparser import parse
+
+class ExpressionParserTest(unittest.TestCase):
+ """Test the conditional expression parser."""
+
+ def test_basic(self):
+
+ self.assertEqual(parse("1"), 1)
+ self.assertEqual(parse("100"), 100)
+ self.assertEqual(parse("true"), True)
+ self.assertEqual(parse("false"), False)
+ self.assertEqual('', parse('""'))
+ self.assertEqual(parse('"foo bar"'), 'foo bar')
+ self.assertEqual(parse("'foo bar'"), 'foo bar')
+ self.assertEqual(parse("foo", foo=1), 1)
+ self.assertEqual(parse("bar", bar=True), True)
+ self.assertEqual(parse("abc123", abc123="xyz"), 'xyz')
+
+ def test_equality(self):
+
+ self.assertTrue(parse("true == true"))
+ self.assertTrue(parse("false == false"))
+ self.assertTrue(parse("1 == 1"))
+ self.assertTrue(parse("100 == 100"))
+ self.assertTrue(parse('"some text" == "some text"'))
+ self.assertTrue(parse("true != false"))
+ self.assertTrue(parse("1 != 2"))
+ self.assertTrue(parse('"text" != "other text"'))
+ self.assertTrue(parse("foo == true", foo=True))
+ self.assertTrue(parse("foo == 1", foo=1))
+ self.assertTrue(parse('foo == "bar"', foo='bar'))
+ self.assertTrue(parse("foo == bar", foo=True, bar=True))
+ self.assertTrue(parse("true == foo", foo=True))
+ self.assertTrue(parse("foo != true", foo=False))
+ self.assertTrue(parse("foo != 2", foo=1))
+ self.assertTrue(parse('foo != "bar"', foo='abc'))
+ self.assertTrue(parse("foo != bar", foo=True, bar=False))
+ self.assertTrue(parse("true != foo", foo=False))
+ self.assertTrue(parse("!false"))
+
+ def test_conjunctures(self):
+ self.assertTrue(parse("true && true"))
+ self.assertTrue(parse("true || false"))
+ self.assertFalse(parse("false || false"))
+ self.assertFalse(parse("true && false"))
+ self.assertTrue(parse("true || false && false"))
+
+ def test_parentheses(self):
+ self.assertTrue(parse("(true)"))
+ self.assertEqual(parse("(10)"), 10)
+ self.assertEqual(parse('("foo")'), 'foo')
+ self.assertEqual(parse("(foo)", foo=1), 1)
+ self.assertTrue(parse("(true == true)"), True)
+ self.assertTrue(parse("(true != false)"))
+ self.assertTrue(parse("(true && true)"))
+ self.assertTrue(parse("(true || false)"))
+ self.assertTrue(parse("(true && true || false)"))
+ self.assertFalse(parse("(true || false) && false"))
+ self.assertTrue(parse("(true || false) && true"))
+ self.assertTrue(parse("true && (true || false)"))
+ self.assertTrue(parse("true && (true || false)"))
+ self.assertTrue(parse("(true && false) || (true && (true || false))"))
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: third_party/manifestdestiny/tests/test_expressionparser.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/manifestdestiny/tests/path-example.ini ('k') | third_party/manifestdestiny/tests/test_manifestparser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698