Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
scripts.templateloader_test.TemplateLoaderTestCase Class Reference
Inheritance diagram for scripts.templateloader_test.TemplateLoaderTestCase:

Public Member Functions

 test_freevar (self)
 
 test_comments (self)
 
 test_ite1 (self)
 
 test_ite2 (self)
 
 test_if1 (self)
 
 test_if2 (self)
 
 test_else1 (self)
 
 test_else2 (self)
 
 test_eof1 (self)
 
 test_eof2 (self)
 

Protected Member Functions

 _preprocess (self, input_text, conds)
 
 _preprocess_test (self, input_text, conds, expected_text)
 
 _preprocess_error_test (self, input_text, conds, expected_message)
 

Detailed Description

Definition at line 11 of file templateloader_test.py.

Member Function Documentation

◆ _preprocess()

scripts.templateloader_test.TemplateLoaderTestCase._preprocess (   self,
  input_text,
  conds 
)
protected

Definition at line 13 of file templateloader_test.py.

13 def _preprocess(self, input_text, conds):
14 loader = templateloader.TemplateLoader('.', [], conds)
15 return loader._Preprocess(input_text, '<file>', conds)
16

◆ _preprocess_error_test()

scripts.templateloader_test.TemplateLoaderTestCase._preprocess_error_test (   self,
  input_text,
  conds,
  expected_message 
)
protected

Definition at line 29 of file templateloader_test.py.

29 def _preprocess_error_test(self, input_text, conds, expected_message):
30 threw = False
31 try:
32 output_text = self._preprocess(input_text, conds)
33 except Exception as e:
34 threw = True
35 if str(e).find(expected_message) == -1:
36 self.fail("'%s' does not contain '%s'" % (e, expected_message))
37 if not threw:
38 self.fail("missing error, expected '%s'" % expected_message)
39
int find(T *array, int N, T item)

◆ _preprocess_test()

scripts.templateloader_test.TemplateLoaderTestCase._preprocess_test (   self,
  input_text,
  conds,
  expected_text 
)
protected

Definition at line 17 of file templateloader_test.py.

17 def _preprocess_test(self, input_text, conds, expected_text):
18 output_text = self._preprocess(input_text, conds)
19 if output_text != expected_text:
20 msg = '''
21EXPECTED:
22%s
23---
24ACTUAL :
25%s
26---''' % (expected_text, output_text)
27 self.fail(msg)
28

◆ test_comments()

scripts.templateloader_test.TemplateLoaderTestCase.test_comments (   self)

Definition at line 45 of file templateloader_test.py.

45 def test_comments(self):
46 input_text = '''//$ comment 1
47Hello
48//$ comment 2'''
49 self._preprocess_test(input_text, {}, 'Hello\n')
50

◆ test_else1()

scripts.templateloader_test.TemplateLoaderTestCase.test_else1 (   self)

Definition at line 98 of file templateloader_test.py.

98 def test_else1(self):
99 input_text = '''
100 $else
101 '''
102 self._preprocess_error_test(input_text, {}, '$else without $if')
103

◆ test_else2()

scripts.templateloader_test.TemplateLoaderTestCase.test_else2 (   self)

Definition at line 104 of file templateloader_test.py.

104 def test_else2(self):
105 input_text = '''
106 $if A
107 $else
108 $else
109 '''
110 self._preprocess_error_test(input_text, {'A': True}, 'Double $else')
111

◆ test_eof1()

scripts.templateloader_test.TemplateLoaderTestCase.test_eof1 (   self)

Definition at line 112 of file templateloader_test.py.

112 def test_eof1(self):
113 input_text = '''
114 $if A
115 '''
116 self._preprocess_error_test(input_text, {'A': True}, 'Unterminated')
117

◆ test_eof2()

scripts.templateloader_test.TemplateLoaderTestCase.test_eof2 (   self)

Definition at line 118 of file templateloader_test.py.

118 def test_eof2(self):
119 input_text = '''
120 $if A
121 $else
122 '''
123 self._preprocess_error_test(input_text, {'A': True}, 'Unterminated')
124
125

◆ test_freevar()

scripts.templateloader_test.TemplateLoaderTestCase.test_freevar (   self)

Definition at line 40 of file templateloader_test.py.

40 def test_freevar(self):
41 input_text = '''$A
42$B'''
43 self._preprocess_test(input_text, {}, input_text)
44

◆ test_if1()

scripts.templateloader_test.TemplateLoaderTestCase.test_if1 (   self)

Definition at line 85 of file templateloader_test.py.

85 def test_if1(self):
86 input_text = '''
87 $if
88 '''
89 self._preprocess_error_test(input_text, {},
90 '$if does not have single variable')
91

◆ test_if2()

scripts.templateloader_test.TemplateLoaderTestCase.test_if2 (   self)

Definition at line 92 of file templateloader_test.py.

92 def test_if2(self):
93 input_text = '''
94 $if A
95 '''
96 self._preprocess_error_test(input_text, {}, 'Unknown $if variable')
97

◆ test_ite1()

scripts.templateloader_test.TemplateLoaderTestCase.test_ite1 (   self)

Definition at line 51 of file templateloader_test.py.

51 def test_ite1(self):
52 input_text = '''
53 aaa
54 $if A
55 bbb
56 $else
57 ccc
58 $endif
59 ddd
60 '''
61 self._preprocess_test(
62 input_text, {'A': True}, '''
63 aaa
64 bbb
65 ddd
66 ''')
67

◆ test_ite2()

scripts.templateloader_test.TemplateLoaderTestCase.test_ite2 (   self)

Definition at line 68 of file templateloader_test.py.

68 def test_ite2(self):
69 input_text = '''
70 aaa
71 $if A
72 bbb
73 $else
74 ccc
75 $endif
76 ddd
77 '''
78 self._preprocess_test(
79 input_text, {'A': False}, '''
80 aaa
81 ccc
82 ddd
83 ''')
84

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