Bug 992621 - Add preprocessor tests for common use of && and || in ifdefs. r=gps
authorJan Beich <jbeich@tormail.org>
Sun, 06 Apr 2014 00:31:00 -0400
changeset 198569 b95f1f575327b0544dc28ca55444cd6bc7eb3c15
parent 198568 347ecbf31a6a06e838fefa3992ddab8ef1655e3a
child 198570 550235d15537c13272fa4458b9bc50f1cfb96420
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs992621
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 992621 - Add preprocessor tests for common use of && and || in ifdefs. r=gps
python/mozbuild/mozbuild/test/test_preprocessor.py
--- a/python/mozbuild/mozbuild/test/test_preprocessor.py
+++ b/python/mozbuild/mozbuild/test/test_preprocessor.py
@@ -87,16 +87,25 @@ class TestPreprocessor(unittest.TestCase
         self.do_include_pass([
             '#if 1',
             'PASS',
             '#else',
             'FAIL',
             '#endif',
         ])
 
+    def test_conditional_if_0_or_1(self):
+        self.do_include_pass([
+            '#if 0 || 1',
+            'PASS',
+            '#else',
+            'FAIL',
+            '#endif',
+        ])
+
     def test_conditional_if_1_elif_1_else(self):
         self.do_include_pass([
             '#if 1',
             'PASS',
             '#elif 1',
             'FAIL',
             '#else',
             'FAIL',
@@ -120,16 +129,25 @@ class TestPreprocessor(unittest.TestCase
         self.do_include_pass([
             '#if !0',
             'PASS',
             '#else',
             'FAIL',
             '#endif',
         ])
 
+    def test_conditional_not_0_and_1(self):
+        self.do_include_pass([
+            '#if !0 && !1',
+            'FAIL',
+            '#else',
+            'PASS',
+            '#endif',
+        ])
+
     def test_conditional_not_1(self):
         self.do_include_pass([
             '#if !1',
             'FAIL',
             '#else',
             'PASS',
             '#endif',
         ])
@@ -356,16 +374,26 @@ class TestPreprocessor(unittest.TestCase
             '#define VAR 0',
             '#ifdef VAR',
             'PASS',
             '#else',
             'FAIL',
             '#endif',
         ])
 
+    def test_var_ifdef_1_or_undef(self):
+        self.do_include_pass([
+            '#define FOO 1',
+            '#if defined(FOO) || defined(BAR)',
+            'PASS',
+            '#else',
+            'FAIL',
+            '#endif',
+        ])
+
     def test_var_ifdef_undef(self):
         self.do_include_pass([
             '#define VAR 0',
             '#undef VAR',
             '#ifdef VAR',
             'FAIL',
             '#else',
             'PASS',
@@ -377,16 +405,26 @@ class TestPreprocessor(unittest.TestCase
             '#define VAR 0',
             '#ifndef VAR',
             'FAIL',
             '#else',
             'PASS',
             '#endif',
         ])
 
+    def test_var_ifndef_0_and_undef(self):
+        self.do_include_pass([
+            '#define FOO 0',
+            '#if !defined(FOO) && !defined(BAR)',
+            'FAIL',
+            '#else',
+            'PASS',
+            '#endif',
+        ])
+
     def test_var_ifndef_undef(self):
         self.do_include_pass([
             '#define VAR 0',
             '#undef VAR',
             '#ifndef VAR',
             'PASS',
             '#else',
             'FAIL',