Annotate

spec/util_interpolation_spec.lua @ 10350:75eab21b7968

util.interpolation: Test #1452
author Kim Alvefur <zash@zash.se>
date Sun, 20 Oct 2019 20:53:41 +0200
parent 9737:3d6f5b20cca6
child 10351:72b23c5f74fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9737
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local template = [[
10350
75eab21b7968 util.interpolation: Test #1452
Kim Alvefur <zash@zash.se>
parents: 9737
diff changeset
2 {greet!?Hi}, {name?world}!
9737
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 ]];
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 local expect1 = [[
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 Hello, WORLD!
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 ]];
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 local expect2 = [[
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 Hello, world!
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 ]];
10350
75eab21b7968 util.interpolation: Test #1452
Kim Alvefur <zash@zash.se>
parents: 9737
diff changeset
10 local expect3 = [[
75eab21b7968 util.interpolation: Test #1452
Kim Alvefur <zash@zash.se>
parents: 9737
diff changeset
11 Hi, YOU!
75eab21b7968 util.interpolation: Test #1452
Kim Alvefur <zash@zash.se>
parents: 9737
diff changeset
12 ]];
9737
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 describe("util.interpolation", function ()
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 it("renders", function ()
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 local render = require "util.interpolation".new("%b{}", string.upper);
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 assert.equal(expect1, render(template, { greet = "Hello", name = "world" }));
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 assert.equal(expect2, render(template, { greet = "Hello" }));
10350
75eab21b7968 util.interpolation: Test #1452
Kim Alvefur <zash@zash.se>
parents: 9737
diff changeset
19 assert.equal(expect3, render(template, { name = "you" }));
9737
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 end);
3d6f5b20cca6 spec: Stub tests for util.interpolation
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 end);