s.
fileSystem.file('c.jl').writeAsStringSync(
'GoodbyeYes');
// d.jl
// This should not output "Yes", either.
// It should actually produce the same as c.jl, since it doesn't define any unique blocks.
fileSystem.file('d.jl').writeAsStringSync(
'Saluton!Yes');
// e.jl
fileSystem.file('e.jl').writeAsStringSync(
'Angel default');
// fox.jl
fileSystem.file('fox.jl').writeAsStringSync(
'The name is default-name
');
// trot.jl
fileSystem.file('trot.jl').writeAsStringSync(
'CONGA YEAH');
// foxtrot.jl
fileSystem.file('foxtrot.jl').writeAsStringSync(
'framework');
});
test('blocks are replaced or kept', () async {
var file = fileSystem.file('c.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 = CodeBuffer();
var scope = SymbolTable();
const jael.Renderer().render(processed!, buf, scope);
print(buf);
expect(
buf.toString(),
'''
a.jl
Goodbye
'''
.trim());
});
test('block defaults are emitted', () async {
var file = fileSystem.file('b.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 = CodeBuffer();
var scope = SymbolTable();
const jael.Renderer().render(processed!, buf, scope);
print(buf);
expect(
buf.toString(),
'''
a.jl
Hello
'''
.trim());
});
test('block resolution only redefines blocks at one level at a time',
() async {
var file = fileSystem.file('d.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 = CodeBuffer();
var scope = SymbolTable();
const jael.Renderer().render(processed!, buf, scope);
print(buf);
expect(
buf.toString(),
'''
a.jl
Goodbye
'''
.trim());
});
test('blocks within blocks', () async {
var file = fileSystem.file('foxtrot.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 = CodeBuffer();
var scope = SymbolTable();
const jael.Renderer().render(processed!, buf, scope);
print(buf);
expect(
buf.toString(),
'''
The name is CONGA
framework
'''
.trim());
});
}