diff --git a/spec/assertions_spec.lua b/spec/assertions_spec.lua index c07d8d9..70a071d 100644 --- a/spec/assertions_spec.lua +++ b/spec/assertions_spec.lua @@ -348,27 +348,37 @@ describe("Test Assertions", function() it("Checks '_' chaining of modifiers and assertions", function() assert.is_string("abc") + assert.is_a_string("abc") assert.is_true(true) assert.is_not_string(123) + assert.is_not_a_string(123) assert.is_nil(nil) assert.is_not_nil({}) assert.is_not_true(false) assert.is_not_false(true) + assert.are_the_same({a=1}, {a=1}) + assert.are_not_the_same({a=1}, {b=1}) -- verify that failing assertions actually fail assert.has_error(function() assert.is_string(1) end) assert.has_error(function() assert.is_true(false) end) assert.has_error(function() assert.is_not_string('string!') end) + assert.has_error(function() assert.is_not_a_string('string!') end) assert.has_error(function() assert.is_nil({}) end) assert.has_error(function() assert.is_not_nil(nil) end) assert.has_error(function() assert.is_not_true(true) end) assert.has_error(function() assert.is_not_false(false) end) + assert.has_error(function() assert.are_the_same({a=1}, {b=1}) end) + assert.has_a_error(function() assert.are_not_the_same({a=1}, {a=1}) end) + assert.has_an_error(function() assert.are_not_the_same({a=1}, {a=1}) end) end) it("Checks '.' chaining of modifiers and assertions", function() assert.is.string("abc") + assert.is.a.string("abc") assert.is.True(true) assert.is.Not.string(123) + assert.is.Not.a.string(123) assert.is.Nil(nil) assert.is.Not.Nil({}) assert.is.Not.True(false) @@ -376,11 +386,15 @@ describe("Test Assertions", function() assert.equals.Not(true, false) assert.equals.Not.Not(true, true) assert.Not.equals.Not(true, true) + assert.are.the.same({a=1}, {a=1}) + assert.are.Not.the.same({a=1}, {b=1}) -- verify that failing assertions actually fail assert.has.error(function() assert.is.string(1) end) + assert.has.error(function() assert.is.a.string(1) end) assert.has.error(function() assert.is.True(false) end) assert.has.error(function() assert.is.Not.string('string!') end) + assert.has.error(function() assert.is.Not.a.string('string!') end) assert.has.error(function() assert.is.Nil({}) end) assert.has.error(function() assert.is.Not.Nil(nil) end) assert.has.error(function() assert.is.Not.True(true) end) @@ -388,6 +402,9 @@ describe("Test Assertions", function() assert.has.error(function() assert.equals.Not(true, true) end) assert.has.error(function() assert.equals.Not.Not(true, false) end) assert.has.error(function() assert.Not.equals.Not(true, false) end) + assert.has.error(function() assert.are.the.same({a=1}, {b=1}) end) + assert.has.a.error(function() assert.are.Not.the.same({a=1}, {a=1}) end) + assert.has.an.error(function() assert.are.Not.the.same({a=1}, {a=1}) end) end) it("Checks number of returned arguments", function() diff --git a/src/modifiers.lua b/src/modifiers.lua index 9493228..c74a1ef 100644 --- a/src/modifiers.lua +++ b/src/modifiers.lua @@ -10,6 +10,9 @@ local function is_not(state) return state end +assert:register("modifier", "a", is) +assert:register("modifier", "an", is) +assert:register("modifier", "the", is) assert:register("modifier", "is", is) assert:register("modifier", "are", is) assert:register("modifier", "was", is)