From 8a184dea2f5189c39ba9d1bfe617fc38dba2b2cb Mon Sep 17 00:00:00 2001 From: Patrick Steele-Idem Date: Thu, 11 Feb 2016 15:45:10 -0700 Subject: [PATCH] Marko v3: Moved over some of the pending compiler tests --- .../custom-tag-data/expected.js | 1 - .../custom-tag-data/template.marko | 2 -- .../autotest-pending/imports/expected.js | 1 - .../autotest-pending/imports/template.marko | 7 ---- .../autotest-pending/macros/expected.js | 1 - .../custom-tag-data/custom-tag-data-tag.js | 1 + .../autotest/custom-tag-data/expected.js | 30 +++++++++++++++++ .../custom-tag-data/marko-taglib.json | 7 ++++ .../autotest/custom-tag-data/template.marko | 3 ++ .../compiler/autotest/macros/expected.js | 33 +++++++++++++++++++ .../macros/template.marko | 4 +-- 11 files changed, 76 insertions(+), 14 deletions(-) delete mode 100644 test/fixtures/compiler/autotest-pending/custom-tag-data/expected.js delete mode 100644 test/fixtures/compiler/autotest-pending/custom-tag-data/template.marko delete mode 100644 test/fixtures/compiler/autotest-pending/imports/expected.js delete mode 100644 test/fixtures/compiler/autotest-pending/imports/template.marko delete mode 100644 test/fixtures/compiler/autotest-pending/macros/expected.js create mode 100644 test/fixtures/compiler/autotest/custom-tag-data/custom-tag-data-tag.js create mode 100644 test/fixtures/compiler/autotest/custom-tag-data/expected.js create mode 100644 test/fixtures/compiler/autotest/custom-tag-data/marko-taglib.json create mode 100644 test/fixtures/compiler/autotest/custom-tag-data/template.marko create mode 100644 test/fixtures/compiler/autotest/macros/expected.js rename test/fixtures/compiler/{autotest-pending => autotest}/macros/template.marko (78%) diff --git a/test/fixtures/compiler/autotest-pending/custom-tag-data/expected.js b/test/fixtures/compiler/autotest-pending/custom-tag-data/expected.js deleted file mode 100644 index 2fd9f9570..000000000 --- a/test/fixtures/compiler/autotest-pending/custom-tag-data/expected.js +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/test/fixtures/compiler/autotest-pending/custom-tag-data/template.marko b/test/fixtures/compiler/autotest-pending/custom-tag-data/template.marko deleted file mode 100644 index 569ee3d83..000000000 --- a/test/fixtures/compiler/autotest-pending/custom-tag-data/template.marko +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/test/fixtures/compiler/autotest-pending/imports/expected.js b/test/fixtures/compiler/autotest-pending/imports/expected.js deleted file mode 100644 index 2fd9f9570..000000000 --- a/test/fixtures/compiler/autotest-pending/imports/expected.js +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/test/fixtures/compiler/autotest-pending/imports/template.marko b/test/fixtures/compiler/autotest-pending/imports/template.marko deleted file mode 100644 index b7202ffd5..000000000 --- a/test/fixtures/compiler/autotest-pending/imports/template.marko +++ /dev/null @@ -1,7 +0,0 @@ - - reverse from "./helpers"; - foo from "./foo"; - - -Hello ${reverse('Frank')} - diff --git a/test/fixtures/compiler/autotest-pending/macros/expected.js b/test/fixtures/compiler/autotest-pending/macros/expected.js deleted file mode 100644 index 2fd9f9570..000000000 --- a/test/fixtures/compiler/autotest-pending/macros/expected.js +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/test/fixtures/compiler/autotest/custom-tag-data/custom-tag-data-tag.js b/test/fixtures/compiler/autotest/custom-tag-data/custom-tag-data-tag.js new file mode 100644 index 000000000..0236c22bc --- /dev/null +++ b/test/fixtures/compiler/autotest/custom-tag-data/custom-tag-data-tag.js @@ -0,0 +1 @@ +module.exports = function(input, out) {}; \ No newline at end of file diff --git a/test/fixtures/compiler/autotest/custom-tag-data/expected.js b/test/fixtures/compiler/autotest/custom-tag-data/expected.js new file mode 100644 index 000000000..ee8fd0d07 --- /dev/null +++ b/test/fixtures/compiler/autotest/custom-tag-data/expected.js @@ -0,0 +1,30 @@ +function create(__helpers) { + var str = __helpers.s, + empty = __helpers.e, + notEmpty = __helpers.ne, + escapeXml = __helpers.x, + __loadTag = __helpers.t, + custom_tag_data = __loadTag(require("./custom-tag-data-tag")), + __merge = __helpers.m; + + return function render(data, out) { + custom_tag_data({ + name: "Frank", + age: 32 + }, out); + + custom_tag_data({ + name: "Frank".toUpperCase(), + age: 32 + }, out); + + custom_tag_data(__merge({ + age: 10 + }, { + name: "Frank", + age: 32 + }), out); + }; +} + +(module.exports = require("marko").c(__filename)).c(create); diff --git a/test/fixtures/compiler/autotest/custom-tag-data/marko-taglib.json b/test/fixtures/compiler/autotest/custom-tag-data/marko-taglib.json new file mode 100644 index 000000000..4fb5c98ec --- /dev/null +++ b/test/fixtures/compiler/autotest/custom-tag-data/marko-taglib.json @@ -0,0 +1,7 @@ +{ + "": { + "renderer": "./custom-tag-data-tag.js", + "@name": "string", + "@age": "integer" + } +} \ No newline at end of file diff --git a/test/fixtures/compiler/autotest/custom-tag-data/template.marko b/test/fixtures/compiler/autotest/custom-tag-data/template.marko new file mode 100644 index 000000000..5d9000b0c --- /dev/null +++ b/test/fixtures/compiler/autotest/custom-tag-data/template.marko @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/fixtures/compiler/autotest/macros/expected.js b/test/fixtures/compiler/autotest/macros/expected.js new file mode 100644 index 000000000..4885a656a --- /dev/null +++ b/test/fixtures/compiler/autotest/macros/expected.js @@ -0,0 +1,33 @@ +function create(__helpers) { + var str = __helpers.s, + empty = __helpers.e, + notEmpty = __helpers.ne, + escapeXml = __helpers.x, + forEach = __helpers.f; + + return function render(data, out) { + function macro_renderTree(node, out, renderBody) { + out.w("Name: " + + escapeXml(node.name) + + " Children: "); + + if (node.children) { + out.w("
    "); + + forEach(node.children, function(child) { + out.w("
  • "); + + macro_renderTree(child, out); + + out.w("
  • "); + }); + + out.w("
"); + } + } + + macro_renderTree(data.node, out); + }; +} + +(module.exports = require("marko").c(__filename)).c(create); diff --git a/test/fixtures/compiler/autotest-pending/macros/template.marko b/test/fixtures/compiler/autotest/macros/template.marko similarity index 78% rename from test/fixtures/compiler/autotest-pending/macros/template.marko rename to test/fixtures/compiler/autotest/macros/template.marko index fbbb39812..8440e1f8c 100644 --- a/test/fixtures/compiler/autotest-pending/macros/template.marko +++ b/test/fixtures/compiler/autotest/macros/template.marko @@ -1,5 +1,5 @@ - Name: ${child.name} + Name: ${node.name} Children:
    @@ -9,4 +9,4 @@
- \ No newline at end of file + \ No newline at end of file