Permalink
Browse files

added first test-stub for memory-allocation

  • Loading branch information...
1 parent 3046e93 commit afe17c2a18a4f790abfd216fc5fcb2e4afd10aa2 @sirlantis committed Jan 2, 2012
Showing with 29 additions and 7 deletions.
  1. +12 −4 test/_helper.coffee
  2. +17 −3 test/futures.coffee
View
@@ -1,4 +1,12 @@
Liquid = require("../src/index")
+Liquid.async.debug = true
+
+# JSON.stringify fails for circular dependencies
+stringify = (v) ->
+ try
+ JSON.stringify(v, null, 2)
+ catch e
+ "Couldn't stringify: #{v}"
global.renderTest = (f) ->
map = {}
@@ -24,19 +32,19 @@ global.renderTest = (f) ->
assert.type actual, "string"
- assert.eql actual, expected, JSON.stringify({
+ assert.eql actual, expected, stringify({
template,
expected,
actual,
assigns
- }, null, 2)
+ })
else
- assert.eql actual, expected, JSON.stringify({
+ assert.eql actual, expected, stringify({
template,
expected,
actual,
assigns
- }, null, 2)
+ })
(exit, assert) ->
f(assertTemplateResult(assert), assert)
View
@@ -1,6 +1,5 @@
-Liquid = require("../src/index")
require "./_helper"
-Liquid.async.debug = true
+Liquid = require("../src/index")
asyncResult = (result) ->
->
@@ -82,4 +81,19 @@ module.exports =
products = ({ id: asyncResult("item#{i}") } for i in [1..3])
render "- item1\n- item2\n- item3\n", doc,
- products: products
+ products: products
+
+ ###
+ TODO: This crashes due to too deep recursion.
+
+ test_too_much_memory: renderTest (render, assert) ->
+ doc = "{{ a"
+ doc += ".a" while doc.length < (1024 * 1024)
+ doc += ".b"
+ doc += " }}"
+
+ a = {}
+ a.a = -> a
+ a.b = -> "STOP"
+
+ render "STOP", doc, a: a

0 comments on commit afe17c2

Please sign in to comment.