Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions spec/dupekey_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- .vscode/settings.json <<
-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'
Expand Down Expand Up @@ -66,4 +62,4 @@ busted.describe("duplicate keys", function()
)
end)
end)
end)
end)
23 changes: 23 additions & 0 deletions spec/empty_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- .vscode/settings.json <<

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry forgot to reply 😿

It seems the original author tend to do so, I believe we could safely remove them if needed

-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'

busted.describe("empty", function()

busted.it("empty:", function()
assert.same(
nil,
yaml.parse([[]])
)
assert.same(
nil,
yaml.parse([[
#END
]])
)
end)
end)
4 changes: 0 additions & 4 deletions spec/example_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- .vscode/settings.json <<
-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'
Expand Down
6 changes: 1 addition & 5 deletions spec/map_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- .vscode/settings.json <<
-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'
Expand Down Expand Up @@ -58,7 +54,7 @@ busted.describe("map", function()
},
yaml.parse([[
a:
- b:
- b:
c: 1
]])
)
Expand Down
4 changes: 0 additions & 4 deletions spec/seq_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- .vscode/settings.json <<
-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'
Expand Down
4 changes: 0 additions & 4 deletions spec/string_spec.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
-- .vscode/settings.json <<
-- "Lua.workspace.library": {
-- "C:\\ProgramData\\chocolatey\\lib\\luarocks\\luarocks-2.4.4-win32\\systree\\share\\lua\\5.1": true
-- },
local busted = require 'busted'
local assert = require 'luassert'
local yaml = require 'tinyyaml'
Expand Down
6 changes: 4 additions & 2 deletions tinyyaml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ end
-- : (list<str>)->dict
local function parsedocuments(lines)
lines = select(lines, function(s) return not isemptyline(s) end)

if #lines == 0 then return nil end
if sfind(lines[1], '^%%YAML') then tremove(lines, 1) end

local root = {}
Expand Down Expand Up @@ -781,7 +781,9 @@ local function parse(source)
end

local docs = parsedocuments(lines)
if #docs == 1 then
if docs == nil then
return nil
elseif #docs == 1 then
return docs[1]
end

Expand Down