summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/parser_spec.lua56
1 files changed, 53 insertions, 3 deletions
diff --git a/spec/parser_spec.lua b/spec/parser_spec.lua
index 53f86a1..f20ae0f 100644
--- a/spec/parser_spec.lua
+++ b/spec/parser_spec.lua
@@ -4,7 +4,7 @@ local parser = require "headers.parser"
describe("Scheme", function()
local headers
- setup(function()
+ before_each(function()
headers = parser.new()
end)
@@ -22,10 +22,60 @@ describe("Scheme", function()
end)
-describe("Standards (tags)", function() -- TODO: Streamline the naming convention standards/tags/aliases?
+describe("Tags", function()
local headers
- setup(function()
+ before_each(function()
headers = parser.new()
end)
+
+ it("can be created with aliases definition without actual aliases", function()
+ headers:parse [[aliases "Example"]]
+ assert.are.same({"Example"}, headers:get_tags())
+ end)
+
+ it("can be created with aliases definition", function()
+ headers:parse [[aliases "Example" {"Alias for Example"}]]
+ assert.are.same({"Example"}, headers:get_tags())
+ end)
+
+ it("can be created with headers definition", function()
+ headers:parse [[headers "Example" {"example.h"}]]
+ assert.are.same({"Example"}, headers:get_tags())
+ end)
+end)
+
+
+describe("Headers", function()
+ local headers
+
+ before_each(function()
+ headers = parser.new()
+ end)
+
+ it("are not available if never assigned", function()
+ headers:parse [[]]
+ assert.is_nil(headers:get_headers("Example"))
+ end)
+
+ it("can be assigned to a tag", function()
+ headers:parse [[headers "Example" {"example.h"}]]
+ assert.are.same({"example.h"}, headers:get_headers("Example"))
+ end)
+
+ it("can be included from another tag", function()
+ headers:parse [[
+ headers "Parent" {"example.h"}
+ headers "Derived" {include "Parent"}
+ ]]
+ assert.are.same({"example.h"}, headers:get_headers("Derived"))
+ end)
+
+ it("can be removed after including from another tag", function()
+ headers:parse [[
+ headers "Parent" {"example.h", "removed.h"}
+ headers "Derived" {include "Parent", remove "removed.h"}
+ ]]
+ assert.are.same({"example.h"}, headers:get_headers("Derived"))
+ end)
end)