local parser = require "headers.parser" describe("Scheme", function() local headers before_each(function() headers = parser.new() end) it("version one is supported", function() assert.has_no.errors(function() headers:parse [[scheme "headers/1"]] end) end) it("is not required", function() assert.has_no.errors(function() headers:parse "" end) end) end) describe("Tags", function() local headers 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)