Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
10349:ddddda2896fd | 10350:75eab21b7968 |
---|---|
1 local template = [[ | 1 local template = [[ |
2 {greet!}, {name?world}! | 2 {greet!?Hi}, {name?world}! |
3 ]]; | 3 ]]; |
4 local expect1 = [[ | 4 local expect1 = [[ |
5 Hello, WORLD! | 5 Hello, WORLD! |
6 ]]; | 6 ]]; |
7 local expect2 = [[ | 7 local expect2 = [[ |
8 Hello, world! | 8 Hello, world! |
9 ]]; | 9 ]]; |
10 local expect3 = [[ | |
11 Hi, YOU! | |
12 ]]; | |
10 | 13 |
11 describe("util.interpolation", function () | 14 describe("util.interpolation", function () |
12 it("renders", function () | 15 it("renders", function () |
13 local render = require "util.interpolation".new("%b{}", string.upper); | 16 local render = require "util.interpolation".new("%b{}", string.upper); |
14 assert.equal(expect1, render(template, { greet = "Hello", name = "world" })); | 17 assert.equal(expect1, render(template, { greet = "Hello", name = "world" })); |
15 assert.equal(expect2, render(template, { greet = "Hello" })); | 18 assert.equal(expect2, render(template, { greet = "Hello" })); |
19 assert.equal(expect3, render(template, { name = "you" })); | |
16 end); | 20 end); |
17 end); | 21 end); |