Skip to content

Commit 4aede8e

Browse files
committed
AI教我写代码
1 parent b1c1436 commit 4aede8e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

json-edit.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ local function decode_object(ast)
290290
statusPos = statusPos + 1
291291
local res = {}
292292
local chr = next_byte()
293-
if chr == 125 --[[ ']' ]] then
293+
if chr == 125 --[[ '}' ]] then
294294
statusPos = statusPos + 1
295295
return json.createEmptyObject()
296296
end
@@ -602,9 +602,9 @@ local function add_prefix(v, pathlst)
602602
return v
603603
end
604604

605-
local OP = {}
605+
local operations = {}
606606

607-
function OP.add(str, option, path, value)
607+
function operations.add(str, option, path, value)
608608
if path == "/" then
609609
return json.beautify(value, option)
610610
end
@@ -639,7 +639,7 @@ function OP.add(str, option, path, value)
639639
end
640640
end
641641

642-
function OP.remove(str, _, path)
642+
function operations.remove(str, _, path)
643643
if path == "/" then
644644
return ""
645645
end
@@ -671,7 +671,7 @@ function OP.remove(str, _, path)
671671
end
672672
end
673673

674-
function OP.replace(str, option, path, value)
674+
function operations.replace(str, option, path, value)
675675
if path == "/" then
676676
return json.beautify(value, option)
677677
end
@@ -705,7 +705,7 @@ function OP.replace(str, option, path, value)
705705
end
706706

707707
local function edit(str, patch, option)
708-
local f = OP[patch.op]
708+
local f = operations[patch.op]
709709
if not f then
710710
error(string_format("invalid op: %s", patch.op))
711711
return

test/conformance.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package.path = table.concat({
44
}, ";")
55

66
JSONLIB = JSONLIB or "json"
7-
local supportBigInt = _VERSION ~= "Lua 5.1" and _VERSION ~= "Lua 5.2"
7+
local isBigIntSupported = _VERSION ~= "Lua 5.1" and _VERSION ~= "Lua 5.2"
88

99
local lt = require "ltest"
1010
local json = require(JSONLIB)
@@ -144,7 +144,7 @@ function other.encode_float()
144144
lt.assertError(json.encode, math.huge)
145145
lt.assertError(json.encode, -math.huge)
146146
lt.assertError(json.encode, 0 / 0)
147-
if supportBigInt then
147+
if isBigIntSupported then
148148
lt.assertEquals(json.encode(BigInt), tostring(BigInt))
149149
end
150150
end
@@ -206,7 +206,7 @@ end
206206

207207
function other.decode()
208208
lt.assertError(json.decode, 1)
209-
if supportBigInt then
209+
if isBigIntSupported then
210210
lt.assertEquals(json.decode(tostring(BigInt)), BigInt)
211211
end
212212
end

test/jsonc.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ local jsonc = require "jsonc"
88

99
local m = lt.test "jsonc"
1010

11-
local function test_yes(input, ouput)
12-
lt.assertEquals(jsonc.encode(jsonc.decode_jsonc(input)), jsonc.encode(ouput))
11+
local function test_yes(input, output)
12+
lt.assertEquals(jsonc.encode(jsonc.decode_jsonc(input)), jsonc.encode(output))
1313
end
1414
local function test_no(input)
1515
lt.assertError(jsonc.decode_jsonc, input)

0 commit comments

Comments
 (0)