diff options
Diffstat (limited to 'node_modules/yamlparser/tests')
-rw-r--r-- | node_modules/yamlparser/tests/example.yml | 62 | ||||
-rw-r--r-- | node_modules/yamlparser/tests/index.html | 26 | ||||
-rw-r--r-- | node_modules/yamlparser/tests/server.js | 13 |
3 files changed, 101 insertions, 0 deletions
diff --git a/node_modules/yamlparser/tests/example.yml b/node_modules/yamlparser/tests/example.yml new file mode 100644 index 0000000..8bd9375 --- /dev/null +++ b/node_modules/yamlparser/tests/example.yml @@ -0,0 +1,62 @@ +--- +# Hello World! + +chart: + - {x: 1993, y: 5} + + - {x: 1994, y: 5} + + - {x: 1995, y: 5} + + - {x: 1996, y: 5} + +multi-level: + - array1: + - 1 + - 2 + - 3 + - 4 + - 5 + - array2: { teste: ah, bah: 123 } + - array3: + - array31: + - array311: [0, 1, 2, 3] + +receipt: Oz-Ware Purchase Invoice # isto é um comentário +date: 2007-08-06 +customer: + given: Dorothy + family: Gale + pessoa: + married: false + money: .NaN + name: {first: "Diogo", last: "Costa"} + surname: Costa + +items: + - part_no: A4786 + descrip: Water Bucket (Filled) + price: 1.47 + quantity: 4 + + - part_no: E1628 + descrip: High Heeled "Ruby" Slippers + size: 8 + price: 100.27 + quantity: 1 + +bill-to: &id001 + street: | + 123 Tornado Alley + Suite 16 + city: East Centerville + state: KS + +ship-to: *id001 + +specialDelivery: > + Follow the Yellow Brick + Road to the Emerald City. + Pay no attention to the man + behind the curtain. +... diff --git a/node_modules/yamlparser/tests/index.html b/node_modules/yamlparser/tests/index.html new file mode 100644 index 0000000..450f672 --- /dev/null +++ b/node_modules/yamlparser/tests/index.html @@ -0,0 +1,26 @@ +<!DOCTYPE HTML> +<html lang="en-US"> +<head> + <meta charset="UTF-8"> + <title>YAML Parser</title> + <script type="text/javascript" src="../src/yamlparser.js"></script> + <script type="text/javascript"> + window.onload = function() { + var test1 = YAML.eval("---\n- one\n- two"); + var test2 = YAML.eval("---\none: two"); + + YAML.fromURL("example.yml", function(data) { + var errors = YAML.getErrors(); + if(errors.length == 0) + document.getElementById("out").innerHTML = "Done! Took " + YAML.getProcessingTime() + " miliseconds."; + else { + document.getElementById("out").innerHTML = errors.join("<br>"); + } + }); + }; + </script> +</head> +<body> + <pre id="out"></pre> +</body> +</html> diff --git a/node_modules/yamlparser/tests/server.js b/node_modules/yamlparser/tests/server.js new file mode 100644 index 0000000..82db54d --- /dev/null +++ b/node_modules/yamlparser/tests/server.js @@ -0,0 +1,13 @@ +var http = require('http'); +var yaml = require('yamlparser'); + +http.createServer(function(req, res) { + res.writeHead(200, {'Content-Type' : 'text/plain' }); + + var fs = require('fs'); + var fileContents = fs.readFileSync('example.yml', 'utf8'); + var data = yaml.eval(fileContents); + res.end(JSON.stringify(data)); +}).listen(8080, "127.0.0.1"); + +console.log('Server running at http://127.0.0.1:8080');
\ No newline at end of file |