fix tests, add pre-commit hook

master
Jordan Orelli 10 years ago
parent b70f370dd1
commit 1f06100987

1
.gitignore vendored

@ -0,0 +1 @@
moon

@ -38,30 +38,27 @@ var primitivesTests = []struct {
{`[]`, []token{{t_list_start, "["}, {t_list_end, "]"}}}, {`[]`, []token{{t_list_start, "["}, {t_list_end, "]"}}},
{`["item"]`, []token{{t_list_start, "["}, {t_string, "item"}, {t_list_end, "]"}}}, {`["item"]`, []token{{t_list_start, "["}, {t_string, "item"}, {t_list_end, "]"}}},
{`{}`, []token{{t_object_start, "{"}, {t_object_end, "}"}}}, {`{}`, []token{{t_object_start, "{"}, {t_object_end, "}"}}},
{`{first_name: "jordan", last_name: "orelli"}`, []token{ {`{first_name: "jordan" last_name: "orelli"}`, []token{
{t_object_start, "{"}, {t_object_start, "{"},
{t_name, "first_name"}, {t_name, "first_name"},
{t_object_separator, ":"}, {t_object_separator, ":"},
{t_string, "jordan"}, {t_string, "jordan"},
{t_list_separator, ","},
{t_name, "last_name"}, {t_name, "last_name"},
{t_object_separator, ":"}, {t_object_separator, ":"},
{t_string, "orelli"}, {t_string, "orelli"},
{t_object_end, "}"}, {t_object_end, "}"},
}}, }},
{`{ {`{
first_name: "jordan", first_name: "jordan"
last_name: "orelli", last_name: "orelli"
}`, []token{ }`, []token{
{t_object_start, "{"}, {t_object_start, "{"},
{t_name, "first_name"}, {t_name, "first_name"},
{t_object_separator, ":"}, {t_object_separator, ":"},
{t_string, "jordan"}, {t_string, "jordan"},
{t_list_separator, ","},
{t_name, "last_name"}, {t_name, "last_name"},
{t_object_separator, ":"}, {t_object_separator, ":"},
{t_string, "orelli"}, {t_string, "orelli"},
{t_list_separator, ","},
{t_object_end, "}"}, {t_object_end, "}"},
}}, }},
{`0`, []token{{t_real_number, "0"}}}, {`0`, []token{{t_real_number, "0"}}},
@ -81,12 +78,10 @@ var primitivesTests = []struct {
{t_real_number, "12.345"}, {t_real_number, "12.345"},
{t_list_end, "]"}, {t_list_end, "]"},
}}, }},
{`[1, 2, 3]`, []token{ {`[1 2 3]`, []token{
{t_list_start, "["}, {t_list_start, "["},
{t_real_number, "1"}, {t_real_number, "1"},
{t_list_separator, ","},
{t_real_number, "2"}, {t_real_number, "2"},
{t_list_separator, ","},
{t_real_number, "3"}, {t_real_number, "3"},
{t_list_end, "]"}, {t_list_end, "]"},
}}, }},

@ -16,9 +16,7 @@ var parseTests = []parseTest{
{ {
source: `# just a comment`, source: `# just a comment`,
root: &rootNode{ root: &rootNode{
children: []node{ children: []node{},
&commentNode{" just a comment"},
},
}, },
}, },
{ {
@ -59,15 +57,13 @@ var parseTests = []parseTest{
root: &rootNode{ root: &rootNode{
children: []node{ children: []node{
&assignmentNode{"first_name", "jordan"}, &assignmentNode{"first_name", "jordan"},
&commentNode{" yep, that's my name"},
&assignmentNode{"last_name", "orelli"}, &assignmentNode{"last_name", "orelli"},
&commentNode{" comments should be able to follow other shit"},
}, },
}, },
}, },
{ {
source: ` source: `
heroes: ["lina", "cm"] heroes: ["lina" "cm"]
`, `,
root: &rootNode{ root: &rootNode{
children: []node{ children: []node{
@ -77,7 +73,7 @@ var parseTests = []parseTest{
}, },
{ {
source: ` source: `
nested: [["one", "two"], ["three", "four"]] nested: [["one" "two"] ["three" "four"]]
`, `,
root: &rootNode{ root: &rootNode{
children: []node{ children: []node{
@ -88,8 +84,8 @@ var parseTests = []parseTest{
{ {
source: ` source: `
nested: [ nested: [
["one", "two"], ["one" "two"]
["three", "four"], ["three" "four"]
] ]
`, `,
root: &rootNode{ root: &rootNode{
@ -100,7 +96,7 @@ var parseTests = []parseTest{
}, },
{ {
source: ` source: `
admin: {first_name: "jordan", last_name: "orelli"} admin: {first_name: "jordan" last_name: "orelli"}
`, `,
root: &rootNode{ root: &rootNode{
children: []node{ children: []node{
@ -114,8 +110,8 @@ var parseTests = []parseTest{
{ {
source: ` source: `
http: { http: {
port: 9000, port: 9000
routes: "/path/to/some/file", routes: "/path/to/some/file"
} }
`, `,
root: &rootNode{ root: &rootNode{

Loading…
Cancel
Save