diff options
author | Aki <please@ignore.pl> | 2024-08-21 01:04:08 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-08-21 01:04:08 +0200 |
commit | 77d198f8e55900dc48520d4fa3c343561daf4db0 (patch) | |
tree | 3bf04b4485bbd79c690aecb9a726e88c3cd2c013 /spec | |
parent | 341f0674861b0592cd359933dc09159b6aa9a394 (diff) | |
download | headers-77d198f8e55900dc48520d4fa3c343561daf4db0.zip headers-77d198f8e55900dc48520d4fa3c343561daf4db0.tar.gz headers-77d198f8e55900dc48520d4fa3c343561daf4db0.tar.bz2 |
Added some dead simple parser tests for own sanity
Diffstat (limited to 'spec')
-rw-r--r-- | spec/parser_spec.lua | 56 |
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) |