summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter van de Bruggen <pvande@gmail.com>2010-12-11 12:38:06 -0800
committerPieter van de Bruggen <pvande@gmail.com>2010-12-11 12:45:37 -0800
commit441328329f3af164d63187d383b8566e2d83bc0d (patch)
tree537641a7461aa23785fadf6ce51cad22a59465fc
parent91930341442a3b9e4591d5f0546f7dec378cace4 (diff)
downloadmustache-spec-441328329f3af164d63187d383b8566e2d83bc0d.tar.gz
Adding Javascript to the lambdas spec.
-rw-r--r--specs/~lambdas.yml8
1 files changed, 8 insertions, 0 deletions
diff --git a/specs/~lambdas.yml b/specs/~lambdas.yml
index 692b41b..308841d 100644
--- a/specs/~lambdas.yml
+++ b/specs/~lambdas.yml
@@ -5,6 +5,7 @@ tests:
lambda: !code
ruby: 'proc { "world" }'
perl: 'sub { "world" }'
+ js: 'function() { return "World" }'
template: "Hello, {{lambda}}!"
expected: "Hello, world!"
@@ -15,6 +16,7 @@ tests:
lambda: !code
ruby: 'proc { "{{planet}}" }'
perl: 'sub { "{{planet}}" }'
+ js: 'function() { return "{{planet}}" }'
template: "Hello, {{lambda}}!"
expected: "Hello, world!"
@@ -24,6 +26,7 @@ tests:
lambda: !code
ruby: 'proc { $calls ||= 0; $calls += 1 }'
perl: 'sub { no strict; $calls += 1 }'
+ js: 'function() { calls ||= 0; return calls++; }'
template: '{{lambda}} == {{{lambda}}} == {{lambda}}'
expected: '1 == 1 == 1'
@@ -36,6 +39,7 @@ tests:
lambda: !code
ruby: 'proc { "Big" }'
perl: 'sub { "Big" }'
+ js: 'function() { return "Big" }'
template: "{{#context}}{{key}} the {{lambda}}{{/context}} {{key}}"
expected: "Under the Big Top"
@@ -45,6 +49,7 @@ tests:
lambda: !code
ruby: 'proc { ">" }'
perl: 'sub { ">" }'
+ js: 'function() { return ">" }'
template: "<{{lambda}}{{{lambda}}}"
expected: "<&gt;>"
@@ -55,6 +60,7 @@ tests:
lambda: !code
ruby: 'proc { |text| text == "{{x}}" ? "yes" : "no" }'
perl: 'sub { $_[0] eq "{{x}}" ? "yes" : "no" }'
+ js: 'function(txt) { return (txt == "{{x}}" ? "yes" : "no") }'
template: "<{{#lambda}}{{x}}{{/lambda}}>"
expected: "<yes>"
@@ -65,6 +71,7 @@ tests:
lambda: !code
ruby: 'proc { |text| "#{text}{{planet}}#{text}" }'
perl: 'sub { $_[0] . "{{planet}}" . $_[0] }'
+ js: 'function(txt) { return txt + "{{planet}}" + txt }'
template: "<{{#lambda}}-{{/lambda}}>"
expected: "<-Earth->"
@@ -75,5 +82,6 @@ tests:
lambda: !code
ruby: 'proc { |text| text }'
perl: 'sub { shift }'
+ js: 'function(txt) { return txt }'
template: "<{{^lambda}}{{static}}{{/lambda}}>"
expected: "<>"