-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for
is_table()
and is_list()
- Loading branch information
1 parent
1b9d9b1
commit 181045f
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- SPDX-FileCopyrightText: Copyright 2022-present Greg Hurrell and contributors. | ||
-- SPDX-License-Identifier: BSD-2-Clause | ||
|
||
local is_list = require('wincent.commandt.private.is_list') | ||
|
||
describe('is_list()', function() | ||
it('identifies an empty list', function() | ||
expect(is_list({})).to_be(true) | ||
end) | ||
|
||
it('identifies a non-empty list', function() | ||
expect(is_list({ 1, 2, 3 })).to_be(true) | ||
expect(is_list({ 'foo', 'bar', 'baz' })).to_be(true) | ||
end) | ||
|
||
it('does not identify a non-empty table as a list', function() | ||
expect(is_list({ foo = true })).to_be(false) | ||
end) | ||
|
||
it('does not identify other types as lists', function() | ||
expect(is_list(0)).to_be(false) | ||
expect(is_list('hello')).to_be(false) | ||
expect(is_list(false)).to_be(false) | ||
expect(is_list(nil)).to_be(false) | ||
expect(is_list(true)).to_be(false) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- SPDX-FileCopyrightText: Copyright 2022-present Greg Hurrell and contributors. | ||
-- SPDX-License-Identifier: BSD-2-Clause | ||
|
||
local is_table = require('wincent.commandt.private.is_table') | ||
|
||
describe('is_table()', function() | ||
it('identifies an empty table', function() | ||
expect(is_table({})).to_be(true) | ||
end) | ||
|
||
it('identifies a non-empty table', function() | ||
expect(is_table({ foo = 'bar' })).to_be(true) | ||
end) | ||
|
||
it('does not identify a list as a table', function() | ||
expect(is_table({ 1, 2, 3 })).to_be(false) | ||
expect(is_table({ 'foo', 'bar', 'baz' })).to_be(false) | ||
end) | ||
|
||
it('does not identify other types as tables', function() | ||
expect(is_table(0)).to_be(false) | ||
expect(is_table('hello')).to_be(false) | ||
expect(is_table(false)).to_be(false) | ||
expect(is_table(nil)).to_be(false) | ||
expect(is_table(true)).to_be(false) | ||
end) | ||
end) |