From 697e33ed224b539a42ff68121f7497f5bbf941b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 14 Jul 2019 08:35:24 +0200 Subject: New upstream version 3.0.5 --- src/engine/SCons/cppTests.py | 145 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 3 deletions(-) (limited to 'src/engine/SCons/cppTests.py') diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 2108277..7ebdf99 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2017 The SCons Foundation +# Copyright (c) 2001 - 2019 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -23,7 +23,7 @@ from __future__ import absolute_import -__revision__ = "src/engine/SCons/cppTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" +__revision__ = "src/engine/SCons/cppTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog" import atexit import sys @@ -346,6 +346,80 @@ nested_ifs_input = """ +ifndef_input = """ +#define DEFINED 0 + +#ifndef DEFINED +#include "file45-no" +#else +#include "file45-yes" +#endif + +#ifndef NOT_DEFINED +#include +#else +#include +#endif +""" + + +if_defined_no_space_input = """ +#define DEFINED 0 + +#if(defined DEFINED) +#include "file47-yes" +#endif + +#if(!defined DEFINED) +#include +#elif(!defined DEFINED) +#include +#else +#include +#endif + +#if!(defined DEFINED) +#include "file51-no" +#elif!(defined DEFINED) +#include +#else +#include "file53-yes" +#endif +""" + +if_no_space_input = """ +#define DEFINED 0 + +#if(DEFINED) +#include "file54-no" +#endif + +#if!(DEFINED) +#include +#elif!(DEFINED) +#include +#endif + +#if(DEFINED) +#include "file57-no" +#elif(!DEFINED) +#include +#endif + +#if!( DEFINED) +#include "file59-yes" +#elif!( DEFINED) +#include +#endif + +#if( DEFINED) +#include "file61-no" +#elif(! DEFINED) +#include +#endif +""" + + # pp_class = PreProcessor # #pp_class = DumbPreProcessor @@ -426,6 +500,25 @@ class cppTestCase(unittest.TestCase): result = self.cpp.process_contents(nested_ifs_input) assert expect == result, (expect, result) + def test_ifndef(self): + """Test basic #ifndef processing""" + expect = self.ifndef_expect + result = self.cpp.process_contents(ifndef_input) + assert expect == result, (expect, result) + + def test_if_defined_no_space(self): + """Test #if(defined, i.e.without space but parenthesis""" + expect = self.if_defined_no_space_expect + result = self.cpp.process_contents(if_defined_no_space_input) + assert expect == result, (expect, result) + + def test_if_no_space(self): + """Test #if(, i.e. without space but parenthesis""" + expect = self.if_no_space_expect + result = self.cpp.process_contents(if_no_space_input) + assert expect == result, (expect, result) + + class cppAllTestCase(cppTestCase): def setUp(self): self.cpp = self.cpp_class(current = ".", @@ -513,6 +606,24 @@ class PreProcessorTestCase(cppAllTestCase): ('include', '"', 'file7-yes'), ] + ifndef_expect = [ + ('include', '"', 'file45-yes'), + ('include', '<', 'file46-yes'), + ] + + if_defined_no_space_expect = [ + ('include', '"', 'file47-yes'), + ('include', '<', 'file50-yes'), + ('include', '"', 'file53-yes'), + ] + + if_no_space_expect = [ + ('include', '<', 'file55-yes'), + ('include', '<', 'file58-yes'), + ('include', '"', 'file59-yes'), + ('include', '<', 'file62-yes'), + ] + class DumbPreProcessorTestCase(cppAllTestCase): cpp_class = cpp.DumbPreProcessor @@ -625,7 +736,34 @@ class DumbPreProcessorTestCase(cppAllTestCase): ('include', '"', 'file7-yes') ] + ifndef_expect = [ + ('include', '"', 'file45-no'), + ('include', '"', 'file45-yes'), + ('include', '<', 'file46-yes'), + ('include', '<', 'file46-no'), + ] + + if_defined_no_space_expect = [ + ('include', '"', 'file47-yes'), + ('include', '<', 'file48-no'), + ('include', '<', 'file49-no'), + ('include', '<', 'file50-yes'), + ('include', '"', 'file51-no'), + ('include', '<', 'file52-no'), + ('include', '"', 'file53-yes'), + ] + if_no_space_expect = [ + ('include', '"', 'file54-no'), + ('include', '<', 'file55-yes'), + ('include', '<', 'file56-no'), + ('include', '"', 'file57-no'), + ('include', '<', 'file58-yes'), + ('include', '"', 'file59-yes'), + ('include', '<', 'file60-no'), + ('include', '"', 'file61-no'), + ('include', '<', 'file62-yes'), + ] import os import re @@ -679,7 +817,8 @@ class fileTestCase(unittest.TestCase): return '\n'.join(map(strip_spaces, lines)) def write(self, file, contents): - open(file, 'w').write(self.strip_initial_spaces(contents)) + with open(file, 'w') as f: + f.write(self.strip_initial_spaces(contents)) def test_basic(self): """Test basic file inclusion""" -- cgit v1.2.3 From efdf3fdbcd2f7654cb8d1209a8b040914437bacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 23 Jul 2019 16:54:06 +0200 Subject: New upstream version 3.1.0 --- src/engine/SCons/cppTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/engine/SCons/cppTests.py') diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 7ebdf99..6d41ab0 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -23,7 +23,7 @@ from __future__ import absolute_import -__revision__ = "src/engine/SCons/cppTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog" +__revision__ = "src/engine/SCons/cppTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" import atexit import sys -- cgit v1.2.3