Add another inheritance test

This commit is contained in:
Tobe O 2018-07-15 16:41:43 -04:00
parent 329b92aa33
commit 4abfc0a582
5 changed files with 59 additions and 6 deletions

View file

@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="blocks within blocks in block_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/jael_preprocessor/test/block_test.dart" />
<option name="scope" value="GROUP_OR_TEST_BY_NAME" />
<option name="testName" value="blocks within blocks" />
<method />
</configuration>
</component>

View file

@ -1,3 +1,6 @@
# 1.0.3
* Update for annoying map casting bug.
# 1.0.2
* Update for DSX support.
* Clear the buffer on errors.

View file

@ -49,7 +49,10 @@ AngelConfigurer jael(Directory viewsDirectory,
}
var buf = createBuffer();
var scope = new SymbolTable(values: locals ?? {});
var scope = new SymbolTable(
values: locals?.keys?.fold<Map<String, dynamic>>(<String, dynamic>{},
(out, k) => out..[k.toString()] = locals[k]) ??
<String, dynamic>{});
if (errors.isEmpty) {
try {

View file

@ -1,5 +1,5 @@
name: angel_jael
version: 1.0.2
version: 1.0.3
description: Angel support for the Jael templating engine.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/jael/tree/master/jael

View file

@ -26,6 +26,14 @@ main() {
// d.jl
fileSystem.file('d.jl').writeAsStringSync(
'<extend src="c.jl"><block name="greeting">Saluton!</block></extend>');
// e.jl
fileSystem.file('e.jl').writeAsStringSync(
'<extend src="c.jl"><block name="greeting">Angel <block name="name">default</block></block></extend>');
// e.jl
fileSystem.file('f.jl').writeAsStringSync(
'<extend src="e.jl"><block name="name">framework</block></extend>');
});
test('blocks are replaced or kept', () async {
@ -40,14 +48,17 @@ main() {
const jael.Renderer().render(processed, buf, scope);
print(buf);
expect(buf.toString(), '''
expect(
buf.toString(),
'''
<i>
<b>
a.jl
</b>
Goodbye
</i>
'''.trim());
'''
.trim());
});
test('block resolution is recursive', () async {
@ -62,13 +73,41 @@ main() {
const jael.Renderer().render(processed, buf, scope);
print(buf);
expect(buf.toString(), '''
expect(
buf.toString(),
'''
<i>
<b>
a.jl
</b>
Saluton!Goodbye
</i>
'''.trim());
'''
.trim());
});
test('blocks within blocks', () async {
var file = fileSystem.file('f.jl');
var original = jael.parseDocument(await file.readAsString(),
sourceUrl: file.uri, onError: (e) => throw e);
var processed = await jael.resolve(
original, fileSystem.directory(fileSystem.currentDirectory),
onError: (e) => throw e);
var buf = new CodeBuffer();
var scope = new SymbolTable();
const jael.Renderer().render(processed, buf, scope);
print(buf);
expect(
buf.toString(),
'''
<i>
<b>
a.jl
</b>
Angel frameworkGoodbye
</i>
'''
.trim());
});
}