@@ -77,6 +77,7 @@ abstract class FooBase {
7777class Foo extends FooBase {
7878 String s1 = "s1";
7979 bool b1 = false;
80+ List<int> l1 = [1, 2, 3];
8081}
8182class Bar {}
8283''' );
@@ -119,29 +120,50 @@ class Bar {}
119120 });
120121
121122 test ('with a property map' , () {
122- expect (generatedContent,
123- contains ('static Map<String, Property> propertyMap() => {' ));
123+ expect (
124+ generatedContent,
125+ contains (
126+ 'static Map<String, Property<CT_>> propertyMap<CT_ extends Foo>() => {' ));
124127 });
125128
126129 test ('with a property map with a String property' , () {
127130 expect (generatedContent, contains ('''
128131 's1': Property(
129- getValue: (Object c) => (c as Foo) .s1,
132+ getValue: (CT_ c) => c .s1,
130133 getProperties: _Renderer_String.propertyMap,
131134 ),
132135''' ));
133136 });
134137
135138 test ('with a property map which references the superclass' , () {
136- expect (generatedContent, contains ('..._Renderer_FooBase.propertyMap(),' ));
139+ expect (generatedContent,
140+ contains ('..._Renderer_FooBase.propertyMap<CT_>(),' ));
137141 });
138142
139143 test ('with a property map with a bool property' , () {
140144 expect (generatedContent, contains ('''
141145 'b1': Property(
142- getValue: (Object c) => (c as Foo) .b1,
146+ getValue: (CT_ c) => c .b1,
143147 getProperties: _Renderer_bool.propertyMap,
144- getBool: (Object c) => (c as Foo).b1 == true,
148+ getBool: (CT_ c) => c.b1 == true,
149+ ),
150+ ''' ));
151+ });
152+
153+ test ('with a property map with an Iterable property' , () {
154+ expect (generatedContent, contains ('''
155+ 'l1': Property(
156+ getValue: (CT_ c) => c.l1,
157+ getProperties: _Renderer_List.propertyMap,
158+ isEmptyIterable: (CT_ c) => c.l1?.isEmpty ?? true,
159+ renderIterable:
160+ (CT_ c, RendererBase<CT_> r, List<MustachioNode> ast) {
161+ var buffer = StringBuffer();
162+ for (var e in c.l1) {
163+ buffer.write(_render_int(e, ast, parent: r));
164+ }
165+ return buffer.toString();
166+ },
145167 ),
146168''' ));
147169 });
@@ -202,15 +224,15 @@ import 'package:mustachio/annotations.dart';
202224 test (
203225 'with a property map which references the superclass with a type '
204226 'variable' , () {
205- expect (
206- generatedContent, contains ('..._Renderer_FooBase.propertyMap<T>(),' ));
227+ expect (generatedContent,
228+ contains ('..._Renderer_FooBase.propertyMap<T, CT_ >(),' ));
207229 });
208230
209231 test (
210232 'with a property map which references the superclass with an interface '
211233 'type' , () {
212234 expect (generatedContent,
213- contains ('..._Renderer_BarBase.propertyMap<int>(),' ));
235+ contains ('..._Renderer_BarBase.propertyMap<int, CT_ >(),' ));
214236 });
215237 });
216238
0 commit comments