From 65d2fb1672b2b255024c09f639f2cf22a335be49 Mon Sep 17 00:00:00 2001 From: Leonel Quinteros Date: Mon, 25 Feb 2013 19:14:55 -0300 Subject: [PATCH] Tests modified --- README.md | 1 + tests/example.toml | 15 +------------- tests/extended.toml | 48 +++++++++++++++++++++++++++++++++++++++++++++ tests/test.php | 9 +++++++-- 4 files changed, 57 insertions(+), 16 deletions(-) create mode 100755 tests/extended.toml diff --git a/README.md b/README.md index 3d18a0e..d5cc194 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ TODO - Throw exception on extra chars after keygroup definition - Throw exception on mixed data type arrays - Throw exception on key or keygroup overwriting +- Write better tests. diff --git a/tests/example.toml b/tests/example.toml index d06c1db..32c7a4f 100755 --- a/tests/example.toml +++ b/tests/example.toml @@ -1,7 +1,6 @@ # This is a TOML document. Boom. title = "TOML Example" -crazy-string = "With a comment # inside, escaped quotes \" and [brackets]" [owner] name = "Tom Preston-Werner" @@ -29,20 +28,8 @@ enabled = true [clients] data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it -# Multi-line array check -key = [ - 1, 2, 3, - [ - 1979-05-27T07:32:00Z, - 1979-05-27T07:32:00Z, - ], - [ - "10.0.0.1", "Escaped \" quote" - ] -] - # Line breaks are OK when inside arrays hosts = [ - "alpha # Try this hash", # Comment here, after string hash. + "alpha", "omega" ] diff --git a/tests/extended.toml b/tests/extended.toml new file mode 100755 index 0000000..d06c1db --- /dev/null +++ b/tests/extended.toml @@ -0,0 +1,48 @@ +# This is a TOML document. Boom. + +title = "TOML Example" +crazy-string = "With a comment # inside, escaped quotes \" and [brackets]" + +[owner] +name = "Tom Preston-Werner" +organization = "GitHub" +bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." +dob = 1979-05-27T07:32:00Z # First class dates? Why not? + +[database] +server = "192.168.1.1" +ports = [ 8001, 8001, 8002 ] +connection_max = 5000 +enabled = true + +[servers] + + # You can indent as you please. Tabs or spaces. TOML don't care. + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc10" + +[clients] +data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it + +# Multi-line array check +key = [ + 1, 2, 3, + [ + 1979-05-27T07:32:00Z, + 1979-05-27T07:32:00Z, + ], + [ + "10.0.0.1", "Escaped \" quote" + ] +] + +# Line breaks are OK when inside arrays +hosts = [ + "alpha # Try this hash", # Comment here, after string hash. + "omega" +] diff --git a/tests/test.php b/tests/test.php index 916c985..b3b11bf 100755 --- a/tests/test.php +++ b/tests/test.php @@ -4,6 +4,11 @@ require("../src/toml.php"); $result = Toml::parseFile('example.toml'); -echo "\n\nToml::parseFile('example.toml'): \n"; -echo "--------------------------------\n"; +echo "\n\nToml::parseFile('example.toml'): \n\n"; +print_r($result); + + +$result = Toml::parseFile('example.toml'); + +echo "\n\nToml::parseFile('extended.toml'): \n\n"; print_r($result);