Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
unit-Preprocessor.TestPreprocessor Class Reference

List of all members.

Public Member Functions

def setUp
def test_conditional_if_0
def test_string_value
def test_number_value
def test_conditional_if_0_elif_1
def test_conditional_if_1
def test_conditional_if_1_elif_1_else
def test_conditional_if_1_if_1
def test_conditional_not_0
def test_conditional_not_1
def test_conditional_not_emptyval
def test_conditional_not_nullval
def test_expand
def test_undef_defined
def test_undef_undefined
def test_filter_attemptSubstitution
def test_filter_emptyLines
def test_filter_slashslash
def test_filter_spaces
def test_filter_substitution
def test_error
def test_javascript_line
def test_literal
def test_var_directory
def test_var_file
def test_var_if_0
def test_var_if_0_elifdef
def test_var_if_0_elifndef
def test_var_ifdef_0
def test_var_ifdef_undef
def test_var_ifndef_0
def test_var_ifndef_undef
def test_var_line
def test_lineEndings
def test_number_value_equals
def test_number_value_equals_defines
def test_octal_value_equals
def test_octal_value_equals_defines
def test_value_quoted_expansion
def test_octal_value_quoted_expansion
def test_number_value_not_equals_quoted_defines
def test_octal_value_not_equals_quoted_defines

Public Attributes

 pp

Detailed Description

Unit tests for the Context class

Definition at line 16 of file unit-Preprocessor.py.


Member Function Documentation

def unit-Preprocessor.TestPreprocessor.setUp (   self)

Definition at line 21 of file unit-Preprocessor.py.

00021 
00022   def setUp(self):
00023     self.pp = Preprocessor()
00024     self.pp.out = StringIO()

def unit-Preprocessor.TestPreprocessor.test_conditional_if_0 (   self)

Definition at line 25 of file unit-Preprocessor.py.

00025 
00026   def test_conditional_if_0(self):
00027     f = NamedIO("conditional_if_0.in", """#if 0
00028 FAIL
00029 #else
00030 PASS
00031 #endif
00032 """)
00033     self.pp.do_include(f)
00034     self.assertEqual(self.pp.out.getvalue(), "PASS\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_if_0_elif_1 (   self)

Definition at line 57 of file unit-Preprocessor.py.

00057 
00058   def test_conditional_if_0_elif_1(self):
00059     f = NamedIO('conditional_if_0_elif_1.in', '''#if 0
00060 #elif 1
00061 PASS
00062 #else
00063 FAIL
00064 #endif
00065 ''')
00066     self.pp.do_include(f)
00067     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_if_1 (   self)

Definition at line 68 of file unit-Preprocessor.py.

00068 
00069   def test_conditional_if_1(self):
00070     f = NamedIO('conditional_if_1.in', '''#if 1
00071 PASS
00072 #else
00073 FAILE
00074 #endif
00075 ''')
00076     self.pp.do_include(f)
00077     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_if_1_elif_1_else (   self)

Definition at line 78 of file unit-Preprocessor.py.

00078 
00079   def test_conditional_if_1_elif_1_else(self):
00080     f = NamedIO('conditional_if_1_elif_1_else.in', '''#if 1
00081 PASS
00082 #elif 1
00083 FAIL
00084 #else
00085 FAIL
00086 #endif
00087 ''')
00088     self.pp.do_include(f)
00089     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_if_1_if_1 (   self)

Definition at line 90 of file unit-Preprocessor.py.

00090 
00091   def test_conditional_if_1_if_1(self):
00092     f = NamedIO('conditional_if_1_if_1.in', '''#if 1
00093 #if 1
00094 PASS
00095 #else
00096 FAIL
00097 #endif
00098 #else
00099 FAIL
00100 #endif
00101 ''')
00102     self.pp.do_include(f)
00103     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_not_0 (   self)

Definition at line 104 of file unit-Preprocessor.py.

00104 
00105   def test_conditional_not_0(self):
00106     f = NamedIO('conditional_not_0.in', '''#if !0
00107 PASS
00108 #else
00109 FAIL
00110 #endif
00111 ''')
00112     self.pp.do_include(f)
00113     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_not_1 (   self)

Definition at line 114 of file unit-Preprocessor.py.

00114 
00115   def test_conditional_not_1(self):
00116     f = NamedIO('conditional_not_1.in', '''#if !1
00117 FAIL
00118 #else
00119 PASS
00120 #endif
00121 ''')
00122     self.pp.do_include(f)
00123     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_not_emptyval (   self)

Definition at line 124 of file unit-Preprocessor.py.

00124 
00125   def test_conditional_not_emptyval(self):
00126     f = NamedIO('conditional_not_emptyval.in', '''#define EMPTYVAL
00127 #if !EMPTYVAL
00128 FAIL
00129 #else
00130 PASS
00131 #endif
00132 #if EMPTYVAL
00133 PASS
00134 #else
00135 FAIL
00136 #endif
00137 ''')
00138     self.pp.do_include(f)
00139     self.assertEqual(self.pp.out.getvalue(), "PASS\nPASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_conditional_not_nullval (   self)

Definition at line 140 of file unit-Preprocessor.py.

00140 
00141   def test_conditional_not_nullval(self):
00142     f = NamedIO('conditional_not_nullval.in', '''#define NULLVAL 0
00143 #if !NULLVAL
00144 PASS
00145 #else
00146 FAIL
00147 #endif
00148 ''')
00149     self.pp.do_include(f)
00150     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_error (   self)

Definition at line 243 of file unit-Preprocessor.py.

00243 
00244   def test_error(self):
00245     f = NamedIO('error.in', '''#error spit this message out
00246 ''')
00247     caught_msg = None
00248     try:
00249       self.pp.do_include(f)
00250     except Preprocessor.Error, e:
00251       caught_msg = e.args[0][-1]
00252     self.assertEqual(caught_msg, 'spit this message out')
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_expand (   self)

Definition at line 151 of file unit-Preprocessor.py.

00151 
00152   def test_expand(self):
00153     f = NamedIO('expand.in', '''#define ASVAR AS
00154 #expand P__ASVAR__S
00155 ''')
00156     self.pp.do_include(f)
00157     self.assertEqual(self.pp.out.getvalue(), "PASS\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_filter_attemptSubstitution (   self)

Definition at line 172 of file unit-Preprocessor.py.

00172 
00173   def test_filter_attemptSubstitution(self):
00174     f = NamedIO('filter_attemptSubstitution.in', '''#filter attemptSubstitution
00175 P@VAR@ASS
00176 #unfilter attemptSubstitution
00177 ''')
00178     self.pp.do_include(f)
00179     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_filter_emptyLines (   self)

Definition at line 180 of file unit-Preprocessor.py.

00180 
00181   def test_filter_emptyLines(self):
00182     f = NamedIO('filter_emptyLines.in', '''lines with a
00183 
00184 blank line
00185 #filter emptyLines
00186 lines with
00187 
00188 no blank lines
00189 #unfilter emptyLines
00190 yet more lines with
00191 
00192 blank lines
00193 ''')
00194     self.pp.do_include(f)
00195     self.assertEqual(self.pp.out.getvalue(), '''lines with a
00196 
00197 blank line
00198 lines with
00199 no blank lines
00200 yet more lines with
00201 
00202 blank lines
00203 ''')
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_filter_slashslash (   self)

Definition at line 204 of file unit-Preprocessor.py.

00204 
00205   def test_filter_slashslash(self):
00206     f = NamedIO('filter_slashslash.in', '''#filter slashslash
00207 PASS//FAIL  // FAIL
00208 #unfilter slashslash
00209 PASS // PASS
00210 ''')
00211     self.pp.do_include(f)
00212     self.assertEqual(self.pp.out.getvalue(), "PASS\nPASS // PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_filter_spaces (   self)

Definition at line 213 of file unit-Preprocessor.py.

00213 
00214   def test_filter_spaces(self):
00215     f = NamedIO('filter_spaces.in', '''#filter spaces
00216 You should see two nice ascii tables
00217  +-+-+-+
00218  | |   |     |
00219  +-+-+-+
00220 #unfilter spaces
00221 +-+---+
00222 | |   |
00223 +-+---+ 
00224 ''')
00225     self.pp.do_include(f)
00226     self.assertEqual(self.pp.out.getvalue(), """You should see two nice ascii tables
00227 +-+-+-+
00228 | | | |
00229 +-+-+-+
00230 +-+---+
00231 | |   |
00232 +-+---+ 
00233 """)
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_filter_substitution (   self)

Definition at line 234 of file unit-Preprocessor.py.

00234 
00235   def test_filter_substitution(self):
00236     f = NamedIO('filter_substitution.in', '''#define VAR ASS
00237 #filter substitution
00238 P@VAR@
00239 #unfilter substitution
00240 ''')
00241     self.pp.do_include(f)
00242     self.assertEqual(self.pp.out.getvalue(), "PASS\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_javascript_line (   self)

Definition at line 253 of file unit-Preprocessor.py.

00253 
00254   def test_javascript_line(self):
00255     f = NamedIO('javascript_line.js.in', '''// Line 1
00256 #if 0
00257 // line 3
00258 #endif
00259 // line 5
00260 # comment
00261 // line 7
00262 // line 8
00263 // line 9
00264 # another comment
00265 // line 11
00266 #define LINE 1
00267 // line 13, given line number overwritten with 2
00268 ''')
00269     self.pp.do_include(f)
00270     out = """// Line 1
00271 //@line 5 "CWDjavascript_line.js.in"
00272 // line 5
00273 //@line 7 "CWDjavascript_line.js.in"
00274 // line 7
00275 // line 8
00276 // line 9
00277 //@line 11 "CWDjavascript_line.js.in"
00278 // line 11
00279 //@line 2 "CWDjavascript_line.js.in"
00280 // line 13, given line number overwritten with 2
00281 """
00282     out = out.replace('CWD', os.getcwd() + os.path.sep)
00283     self.assertEqual(self.pp.out.getvalue(), out)
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_lineEndings (   self)

Definition at line 399 of file unit-Preprocessor.py.

00399 
00400   def test_lineEndings(self):
00401     f = NamedIO('lineEndings.in', '''first
00402 #literal second
00403 ''')
00404     self.pp.setLineEndings('cr')
00405     self.pp.do_include(f)
00406     self.assertEqual(self.pp.out.getvalue(), "first\rsecond\r")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_literal (   self)

Definition at line 284 of file unit-Preprocessor.py.

00284 
00285   def test_literal(self):
00286     f = NamedIO('literal.in', '''#literal PASS
00287 ''')
00288     self.pp.do_include(f)
00289     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_number_value (   self)

Definition at line 46 of file unit-Preprocessor.py.

00046 
00047   def test_number_value(self):
00048     f = NamedIO("string_value.in", """#define FOO 1
00049 #if FOO
00050 number value is true
00051 #else
00052 number value is false
00053 #endif
00054 """)
00055     self.pp.do_include(f)
00056     self.assertEqual(self.pp.out.getvalue(), "number value is true\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_number_value_equals (   self)

Definition at line 407 of file unit-Preprocessor.py.

00407 
00408   def test_number_value_equals(self):
00409     f = NamedIO("number_value_equals.in", """#define FOO 1000
00410 #if FOO == 1000
00411 number value is equal
00412 #else
00413 number value is not equal
00414 #endif
00415 """)
00416     self.pp.do_include(f)
00417     self.assertEqual(self.pp.out.getvalue(), "number value is equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_number_value_equals_defines (   self)

Definition at line 418 of file unit-Preprocessor.py.

00418 
00419   def test_number_value_equals_defines(self):
00420     f = NamedIO("number_value_equals_defines.in", """#if FOO == 1000
00421 number value is equal
00422 #else
00423 number value is not equal
00424 #endif
00425 """)
00426     self.pp.handleCommandLine(["-DFOO=1000"])
00427     self.pp.do_include(f)
00428     self.assertEqual(self.pp.out.getvalue(), "number value is equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_number_value_not_equals_quoted_defines (   self)

Definition at line 471 of file unit-Preprocessor.py.

00471 
00472   def test_number_value_not_equals_quoted_defines(self):
00473     f = NamedIO("number_value_not_equals_quoted_defines.in", """#if FOO == 1000
00474 number value is equal
00475 #else
00476 number value is not equal
00477 #endif
00478 """)
00479     self.pp.handleCommandLine(['-DFOO="1000"'])
00480     self.pp.do_include(f)
00481     self.assertEqual(self.pp.out.getvalue(), "number value is not equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_octal_value_equals (   self)

Definition at line 429 of file unit-Preprocessor.py.

00429 
00430   def test_octal_value_equals(self):
00431     f = NamedIO("octal_value_equals.in", """#define FOO 0100
00432 #if FOO == 0100
00433 octal value is equal
00434 #else
00435 octal value is not equal
00436 #endif
00437 """)
00438     self.pp.do_include(f)
00439     self.assertEqual(self.pp.out.getvalue(), "octal value is equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_octal_value_equals_defines (   self)

Definition at line 440 of file unit-Preprocessor.py.

00440 
00441   def test_octal_value_equals_defines(self):
00442     f = NamedIO("octal_value_equals_defines.in", """#if FOO == 0100
00443 octal value is equal
00444 #else
00445 octal value is not equal
00446 #endif
00447 """)
00448     self.pp.handleCommandLine(["-DFOO=0100"])
00449     self.pp.do_include(f)
00450     self.assertEqual(self.pp.out.getvalue(), "octal value is equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_octal_value_not_equals_quoted_defines (   self)

Definition at line 482 of file unit-Preprocessor.py.

00482 
00483   def test_octal_value_not_equals_quoted_defines(self):
00484     f = NamedIO("octal_value_not_equals_quoted_defines.in", """#if FOO == 0100
00485 octal value is equal
00486 #else
00487 octal value is not equal
00488 #endif
00489 """)
00490     self.pp.handleCommandLine(['-DFOO="0100"'])
00491     self.pp.do_include(f)
00492     self.assertEqual(self.pp.out.getvalue(), "octal value is not equal\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_octal_value_quoted_expansion (   self)

Definition at line 463 of file unit-Preprocessor.py.

00463 
00464   def test_octal_value_quoted_expansion(self):
00465     f = NamedIO("value_quoted_expansion.in", """#filter substitution
00466 @FOO@
00467 """)
00468     self.pp.handleCommandLine(['-DFOO="0100"'])
00469     self.pp.do_include(f)
00470     self.assertEqual(self.pp.out.getvalue(), '"0100"\n')

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_string_value (   self)

Definition at line 35 of file unit-Preprocessor.py.

00035 
00036   def test_string_value(self):
00037     f = NamedIO("string_value.in", """#define FOO STRING
00038 #if FOO
00039 string value is true
00040 #else
00041 string value is false
00042 #endif
00043 """)
00044     self.pp.do_include(f)
00045     self.assertEqual(self.pp.out.getvalue(), "string value is false\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_undef_defined (   self)

Definition at line 158 of file unit-Preprocessor.py.

00158 
00159   def test_undef_defined(self):
00160     f = NamedIO('undef_defined.in', '''#define BAR
00161 #undef BAR
00162 BAR
00163 ''')
00164     self.pp.do_include(f)
00165     self.assertEqual(self.pp.out.getvalue(), "BAR\n")

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_undef_undefined (   self)

Definition at line 166 of file unit-Preprocessor.py.

00166 
00167   def test_undef_undefined(self):
00168     f = NamedIO('undef_undefined.in', '''#undef VAR
00169 ''')
00170     self.pp.do_include(f)
00171     self.assertEqual(self.pp.out.getvalue(), "")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_value_quoted_expansion (   self)
Quoted values on the commandline don't currently have quotes stripped.
Pike says this is for compat reasons.

Definition at line 451 of file unit-Preprocessor.py.

00451 
00452   def test_value_quoted_expansion(self):
00453     """
00454     Quoted values on the commandline don't currently have quotes stripped.
00455     Pike says this is for compat reasons.
00456     """
00457     f = NamedIO("value_quoted_expansion.in", """#filter substitution
00458 @FOO@
00459 """)
00460     self.pp.handleCommandLine(['-DFOO="ABCD"'])
00461     self.pp.do_include(f)
00462     self.assertEqual(self.pp.out.getvalue(), '"ABCD"\n')

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_directory (   self)

Definition at line 290 of file unit-Preprocessor.py.

00290 
00291   def test_var_directory(self):
00292     f = NamedIO('var_directory.in', '''#ifdef DIRECTORY
00293 PASS
00294 #else
00295 FAIL
00296 #endif
00297 ''')
00298     self.pp.do_include(f)
00299     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_file (   self)

Definition at line 300 of file unit-Preprocessor.py.

00300 
00301   def test_var_file(self):
00302     f = NamedIO('var_file.in', '''#ifdef FILE
00303 PASS
00304 #else
00305 FAIL
00306 #endif
00307 ''')
00308     self.pp.do_include(f)
00309     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_if_0 (   self)

Definition at line 310 of file unit-Preprocessor.py.

00310 
00311   def test_var_if_0(self):
00312     f = NamedIO('var_if_0.in', '''#define VAR 0
00313 #if VAR
00314 FAIL
00315 #else
00316 PASS
00317 #endif
00318 ''')
00319     self.pp.do_include(f)
00320     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_if_0_elifdef (   self)

Definition at line 321 of file unit-Preprocessor.py.

00321 
00322   def test_var_if_0_elifdef(self):
00323     f = NamedIO('var_if_0_elifdef.in', '''#if 0
00324 #elifdef FILE
00325 PASS
00326 #else
00327 FAIL
00328 #endif
00329 ''')
00330     self.pp.do_include(f)
00331     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_if_0_elifndef (   self)

Definition at line 332 of file unit-Preprocessor.py.

00332 
00333   def test_var_if_0_elifndef(self):
00334     f = NamedIO('var_if_0_elifndef.in', '''#if 0
00335 #elifndef VAR
00336 PASS
00337 #else
00338 FAIL
00339 #endif
00340 ''')
00341     self.pp.do_include(f)
00342     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_ifdef_0 (   self)

Definition at line 343 of file unit-Preprocessor.py.

00343 
00344   def test_var_ifdef_0(self):
00345     f = NamedIO('var_ifdef_0.in', '''#define VAR 0
00346 #ifdef VAR
00347 PASS
00348 #else
00349 FAIL
00350 #endif
00351 ''')
00352     self.pp.do_include(f)
00353     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_ifdef_undef (   self)

Definition at line 354 of file unit-Preprocessor.py.

00354 
00355   def test_var_ifdef_undef(self):
00356     f = NamedIO('var_ifdef_undef.in', '''#define VAR 0
00357 #undef VAR
00358 #ifdef VAR
00359 FAIL
00360 #else
00361 PASS
00362 #endif
00363 ''')
00364     self.pp.do_include(f)
00365     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_ifndef_0 (   self)

Definition at line 366 of file unit-Preprocessor.py.

00366 
00367   def test_var_ifndef_0(self):
00368     f = NamedIO('var_ifndef_0.in', '''#define VAR 0
00369 #ifndef VAR
00370 FAIL
00371 #else
00372 PASS
00373 #endif
00374 ''')
00375     self.pp.do_include(f)
00376     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_ifndef_undef (   self)

Definition at line 377 of file unit-Preprocessor.py.

00377 
00378   def test_var_ifndef_undef(self):
00379     f = NamedIO('var_ifndef_undef.in', '''#define VAR 0
00380 #undef VAR
00381 #ifndef VAR
00382 PASS
00383 #else
00384 FAIL
00385 #endif
00386 ''')
00387     self.pp.do_include(f)
00388     self.assertEqual(self.pp.out.getvalue(), "PASS\n")
  

Here is the call graph for this function:

def unit-Preprocessor.TestPreprocessor.test_var_line (   self)

Definition at line 389 of file unit-Preprocessor.py.

00389 
00390   def test_var_line(self):
00391     f = NamedIO('var_line.in', '''#ifdef LINE
00392 PASS
00393 #else
00394 FAIL
00395 #endif
00396 ''')
00397     self.pp.do_include(f)
00398     self.assertEqual(self.pp.out.getvalue(), "PASS\n")

Here is the call graph for this function:


Member Data Documentation

unit-Preprocessor.TestPreprocessor.pp

Definition at line 22 of file unit-Preprocessor.py.


The documentation for this class was generated from the following file: