Skip to content

Commit 5e16363

Browse files
Address PR review feedback: throw on unexpected end of input in Read-LuaValue
1 parent d750a9a commit 5e16363

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/functions/private/Read-LuaValue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Skip-LuaWhitespace
1919

2020
if ($script:luaPos -ge $script:luaString.Length) {
21-
return $null
21+
throw 'Unexpected end of input'
2222
}
2323

2424
$char = $script:luaString[$script:luaPos]

tests/Lua.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,14 @@ B = { val = 2 }
499499
It 'Throws on unterminated table (missing closing brace)' {
500500
{ ConvertFrom-Lua -InputObject '{ a = 1' } | Should -Throw '*Unterminated*'
501501
}
502+
503+
It 'Throws on whitespace-only input' {
504+
{ ConvertFrom-Lua -InputObject ' ' } | Should -Throw '*Unexpected end of input*'
505+
}
506+
507+
It 'Throws on assignment with missing value' {
508+
{ ConvertFrom-Lua -InputObject 'A = ' } | Should -Throw '*Unexpected end of input*'
509+
}
502510
}
503511

504512
Context 'Pipeline input' {

0 commit comments

Comments
 (0)