Tests modified

This commit is contained in:
Leonel Quinteros 2013-02-25 19:14:55 -03:00
parent 82fb6ec5ce
commit 65d2fb1672
4 changed files with 57 additions and 16 deletions

View File

@ -24,6 +24,7 @@ TODO
- Throw exception on extra chars after keygroup definition - Throw exception on extra chars after keygroup definition
- Throw exception on mixed data type arrays - Throw exception on mixed data type arrays
- Throw exception on key or keygroup overwriting - Throw exception on key or keygroup overwriting
- Write better tests.

View File

@ -1,7 +1,6 @@
# This is a TOML document. Boom. # This is a TOML document. Boom.
title = "TOML Example" title = "TOML Example"
crazy-string = "With a comment # inside, escaped quotes \" and [brackets]"
[owner] [owner]
name = "Tom Preston-Werner" name = "Tom Preston-Werner"
@ -29,20 +28,8 @@ enabled = true
[clients] [clients]
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it 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 # Line breaks are OK when inside arrays
hosts = [ hosts = [
"alpha # Try this hash", # Comment here, after string hash. "alpha",
"omega" "omega"
] ]

48
tests/extended.toml Executable file
View File

@ -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"
]

View File

@ -4,6 +4,11 @@ require("../src/toml.php");
$result = Toml::parseFile('example.toml'); $result = Toml::parseFile('example.toml');
echo "\n\nToml::parseFile('example.toml'): \n"; echo "\n\nToml::parseFile('example.toml'): \n\n";
echo "--------------------------------\n"; print_r($result);
$result = Toml::parseFile('example.toml');
echo "\n\nToml::parseFile('extended.toml'): \n\n";
print_r($result); print_r($result);