Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
scripts.emitter_test.EmitterTestCase Class Reference
Inheritance diagram for scripts.emitter_test.EmitterTestCase:

Public Member Functions

def setUp (self)
 
def tearDown (self)
 
def check (self, e, expected)
 
def testExample (self)
 
def testTemplateErrorDuplicate (self)
 
def testTemplate1 (self)
 
def testTemplate2 (self)
 
def testTemplate3 (self)
 
def testTemplate4 (self)
 
def testMissing (self)
 
def testHoleScopes (self)
 
def testNestedTemplates (self)
 
def testNestedTemplates2 (self)
 
def testNestedTemplatesWithFalse (self)
 
def testNestedTemplatesWithFalse2 (self)
 
def testNestedTemplatesWithFalse3 (self)
 
def testNestedTemplateMissingBindings (self)
 
def testNestedTemplateWithNoRightParen (self)
 
def testNestedTemplateWithWrongBinding (self)
 
def testFormat (self)
 

Detailed Description

Definition at line 12 of file emitter_test.py.

Member Function Documentation

◆ check()

def scripts.emitter_test.EmitterTestCase.check (   self,
  e,
  expected 
)

Definition at line 20 of file emitter_test.py.

20 def check(self, e, expected):
21 self.assertEqual(''.join(e.Fragments()), expected)
22
#define check(reporter, ref, unref, make, kill)
Definition: RefCntTest.cpp:85
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ setUp()

def scripts.emitter_test.EmitterTestCase.setUp (   self)

Definition at line 14 of file emitter_test.py.

14 def setUp(self):
15 pass
16

◆ tearDown()

def scripts.emitter_test.EmitterTestCase.tearDown (   self)

Definition at line 17 of file emitter_test.py.

17 def tearDown(self):
18 pass
19

◆ testExample()

def scripts.emitter_test.EmitterTestCase.testExample (   self)

Definition at line 23 of file emitter_test.py.

23 def testExample(self):
24 e = emitter.Emitter()
25 body = e.Emit('$TYPE $NAME() {\n'
26 ' $!BODY\n'
27 '}\n',
28 TYPE='int',
29 NAME='foo')
30 body.Emit('return $VALUE;', VALUE='100')
31 self.check(e, 'int foo() {\n' ' return 100;\n' '}\n')
32

◆ testFormat()

def scripts.emitter_test.EmitterTestCase.testFormat (   self)

Definition at line 135 of file emitter_test.py.

135 def testFormat(self):
136 self.assertEqual(emitter.Format('$A$B', A=1, B=2), '12')
137
138

◆ testHoleScopes()

def scripts.emitter_test.EmitterTestCase.testHoleScopes (   self)

Definition at line 72 of file emitter_test.py.

72 def testHoleScopes(self):
73 e = emitter.Emitter()
74 # Holes have scope. They remember the bindings of the template application
75 # in which they are created. Create two holes which inherit bindings for C
76 # and D.
77 (a, b) = e.Emit('[$!A][$!B]$C$D$E', C='1', D='2')
78 e.Emit(' $A$B$C$D') # Bindings are local to the Emit
79 self.check(e, '[][]12$E $A$B$C$D')
80
81 # Holes are not bound within holes. That would too easily lead to infinite
82 # expansions.
83 a.Emit('$A$C$D') # $A12
84 b.Emit('$D$C$B') # 21$B
85 self.check(e, '[$A12][21$B]12$E $A$B$C$D')
86 # EmitRaw avoids interpolation.
87 a.EmitRaw('$C$D')
88 b.EmitRaw('$D$C')
89 self.check(e, '[$A12$C$D][21$B$D$C]12$E $A$B$C$D')
90

◆ testMissing()

def scripts.emitter_test.EmitterTestCase.testMissing (   self)

Definition at line 66 of file emitter_test.py.

66 def testMissing(self):
67 # Behaviour of Undefined parameters depends on form.
68 e = emitter.Emitter()
69 e.Emit('$A $?B $(C) $(?D)')
70 self.check(e, '$A $(C) ')
71

◆ testNestedTemplateMissingBindings()

def scripts.emitter_test.EmitterTestCase.testNestedTemplateMissingBindings (   self)

Definition at line 116 of file emitter_test.py.

116 def testNestedTemplateMissingBindings(self):
117 e = emitter.Emitter()
118 e.Emit('-$#A(-$#B(-$C-)-)-', C='1')
119 self.check(e, '-$#A(-$#B(-1-)-)-')
120

◆ testNestedTemplates()

def scripts.emitter_test.EmitterTestCase.testNestedTemplates (   self)

Definition at line 91 of file emitter_test.py.

91 def testNestedTemplates(self):
92 e = emitter.Emitter()
93 e.Emit('-$#A(-)-', A=True)
94 self.check(e, '---')
95

◆ testNestedTemplates2()

def scripts.emitter_test.EmitterTestCase.testNestedTemplates2 (   self)

Definition at line 96 of file emitter_test.py.

96 def testNestedTemplates2(self):
97 e = emitter.Emitter()
98 e.Emit('-$#A( $#B(-$C-) )-', A=True, B=True, C='1')
99 self.check(e, '- -1- -')
100

◆ testNestedTemplatesWithFalse()

def scripts.emitter_test.EmitterTestCase.testNestedTemplatesWithFalse (   self)

Definition at line 101 of file emitter_test.py.

101 def testNestedTemplatesWithFalse(self):
102 e = emitter.Emitter()
103 e.Emit('-$#A( $B )-', A=False, B='1')
104 self.check(e, '--')
105

◆ testNestedTemplatesWithFalse2()

def scripts.emitter_test.EmitterTestCase.testNestedTemplatesWithFalse2 (   self)

Definition at line 106 of file emitter_test.py.

106 def testNestedTemplatesWithFalse2(self):
107 e = emitter.Emitter()
108 e.Emit('-$#A( $#B(-$C-) )-', A=False, B=True, C='1')
109 self.check(e, '--')
110

◆ testNestedTemplatesWithFalse3()

def scripts.emitter_test.EmitterTestCase.testNestedTemplatesWithFalse3 (   self)

Definition at line 111 of file emitter_test.py.

111 def testNestedTemplatesWithFalse3(self):
112 e = emitter.Emitter()
113 e.Emit('-$#A( $#B(-$C-) )-', A=True, B=False, C='1')
114 self.check(e, '- -')
115

◆ testNestedTemplateWithNoRightParen()

def scripts.emitter_test.EmitterTestCase.testNestedTemplateWithNoRightParen (   self)

Definition at line 121 of file emitter_test.py.

121 def testNestedTemplateWithNoRightParen(self):
122 e = emitter.Emitter()
123 e.Emit('-$#A(-$B-', A=True, B='1')
124 self.check(e, '-$#A(-1-')
125

◆ testNestedTemplateWithWrongBinding()

def scripts.emitter_test.EmitterTestCase.testNestedTemplateWithWrongBinding (   self)

Definition at line 126 of file emitter_test.py.

126 def testNestedTemplateWithWrongBinding(self):
127 try:
128 e = emitter.Emitter()
129 e.Emit('$#A(-)', A='Invalid')
130 e.Fragments()
131 except RuntimeError as ex:
132 return
133 raise AssertionError('Expected error')
134

◆ testTemplate1()

def scripts.emitter_test.EmitterTestCase.testTemplate1 (   self)

Definition at line 41 of file emitter_test.py.

41 def testTemplate1(self):
42 e = emitter.Emitter()
43 e.Emit('-$A+$B-$A+$B-', A='1', B='2')
44 self.check(e, '-1+2-1+2-')
45

◆ testTemplate2()

def scripts.emitter_test.EmitterTestCase.testTemplate2 (   self)

Definition at line 46 of file emitter_test.py.

46 def testTemplate2(self):
47 e = emitter.Emitter()
48 r = e.Emit('1$(A)2$(B)3$(A)4$(B)5', A='x', B='y')
49 self.assertEqual(None, r)
50 self.check(e, '1x2y3x4y5')
51

◆ testTemplate3()

def scripts.emitter_test.EmitterTestCase.testTemplate3 (   self)

Definition at line 52 of file emitter_test.py.

52 def testTemplate3(self):
53 e = emitter.Emitter()
54 b = e.Emit('1$(A)2$(!B)3$(A)4$(B)5', A='x')
55 b.Emit('y')
56 self.check(e, '1x2y3x4y5')
57 self.check(b, 'y')
58

◆ testTemplate4()

def scripts.emitter_test.EmitterTestCase.testTemplate4 (   self)

Definition at line 59 of file emitter_test.py.

59 def testTemplate4(self):
60 e = emitter.Emitter()
61 (a, b) = e.Emit('$!A$!B$A$B') # pair of holes.
62 a.Emit('x')
63 b.Emit('y')
64 self.check(e, 'xyxy')
65

◆ testTemplateErrorDuplicate()

def scripts.emitter_test.EmitterTestCase.testTemplateErrorDuplicate (   self)

Definition at line 33 of file emitter_test.py.

33 def testTemplateErrorDuplicate(self):
34 try:
35 e = emitter.Emitter()
36 b = e.Emit('$(A)$(!B)$(A)$(!B)') # $(!B) is duplicated
37 except RuntimeError as ex:
38 return
39 raise AssertionError('Expected error')
40

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