summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Appel <Dan.appel00@gmail.com>2021-03-30 18:04:59 -0700
committerGitHub <noreply@github.com>2021-03-30 18:04:59 -0700
commitb1329a25e6d265ff360267d23f7c6327bbf59f52 (patch)
tree12ebdba184b9d83dc2225f4d26c7d9d0e30a47dd
parent86fe766daff2cd776af016af6ce101f0d0b00a77 (diff)
parent42ac090a06435dc9790d06a4d71724158c05a3a8 (diff)
downloadmustache-spec-b1329a25e6d265ff360267d23f7c6327bbf59f52.tar.gz
Merge pull request #121 from softmoth/json-code-tag
Fix Rakefile to add __tag__: code for ~lambda test data
-rw-r--r--Rakefile9
-rw-r--r--specs/~lambdas.json10
2 files changed, 17 insertions, 2 deletions
diff --git a/Rakefile b/Rakefile
index 6c6008f..c745f99 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,10 +2,15 @@ require 'json'
require 'yaml'
# Our custom YAML tags must retain their magic.
-%w[ code ].each do |tag|
- YAML::add_builtin_type(tag) { |_,val| val.merge(:__tag__ => tag) }
+class TaggedMap < Hash
+ yaml_tag '!code'
+ def init_with(psych_coder)
+ self.replace({:__tag__ => 'code'}.merge(psych_coder.map))
+ end
end
+YAML::add_tag('code', TaggedMap)
+
desc 'Build all alternate versions of the specs.'
multitask :build => [ 'build:json' ]
diff --git a/specs/~lambdas.json b/specs/~lambdas.json
index c0362ac..7b6d59c 100644
--- a/specs/~lambdas.json
+++ b/specs/~lambdas.json
@@ -7,6 +7,7 @@
"desc": "A lambda's return value should be interpolated.",
"data": {
"lambda": {
+ "__tag__": "code",
"ruby": "proc { \"world\" }",
"raku": "sub { \"world\" }",
"perl": "sub { \"world\" }",
@@ -26,6 +27,7 @@
"data": {
"planet": "world",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { \"{{planet}}\" }",
"raku": "sub { q+{{planet}}+ }",
"perl": "sub { \"{{planet}}\" }",
@@ -45,6 +47,7 @@
"data": {
"planet": "world",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { \"|planet| => {{planet}}\" }",
"raku": "sub { q+|planet| => {{planet}}+ }",
"perl": "sub { \"|planet| => {{planet}}\" }",
@@ -63,6 +66,7 @@
"desc": "Interpolated lambdas should not be cached.",
"data": {
"lambda": {
+ "__tag__": "code",
"ruby": "proc { $calls ||= 0; $calls += 1 }",
"raku": "sub { state $calls += 1 }",
"perl": "sub { no strict; $calls += 1 }",
@@ -81,6 +85,7 @@
"desc": "Lambda results should be appropriately escaped.",
"data": {
"lambda": {
+ "__tag__": "code",
"ruby": "proc { \">\" }",
"raku": "sub { \">\" }",
"perl": "sub { \">\" }",
@@ -100,6 +105,7 @@
"data": {
"x": "Error!",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { |text| text == \"{{x}}\" ? \"yes\" : \"no\" }",
"raku": "sub { $^section eq q+{{x}}+ ?? \"yes\" !! \"no\" }",
"perl": "sub { $_[0] eq \"{{x}}\" ? \"yes\" : \"no\" }",
@@ -119,6 +125,7 @@
"data": {
"planet": "Earth",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { |text| \"#{text}{{planet}}#{text}\" }",
"raku": "sub { $^section ~ q+{{planet}}+ ~ $^section }",
"perl": "sub { $_[0] . \"{{planet}}\" . $_[0] }",
@@ -138,6 +145,7 @@
"data": {
"planet": "Earth",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { |text| \"#{text}{{planet}} => |planet|#{text}\" }",
"raku": "sub { $^section ~ q+{{planet}} => |planet|+ ~ $^section }",
"perl": "sub { $_[0] . \"{{planet}} => |planet|\" . $_[0] }",
@@ -156,6 +164,7 @@
"desc": "Lambdas used for sections should not be cached.",
"data": {
"lambda": {
+ "__tag__": "code",
"ruby": "proc { |text| \"__#{text}__\" }",
"raku": "sub { \"__\" ~ $^section ~ \"__\" }",
"perl": "sub { \"__\" . $_[0] . \"__\" }",
@@ -175,6 +184,7 @@
"data": {
"static": "static",
"lambda": {
+ "__tag__": "code",
"ruby": "proc { |text| false }",
"raku": "sub { 0 }",
"perl": "sub { 0 }",