Skip to content

Commit 2f0086e

Browse files
committed
Add direct empty object tests
1 parent 30f7842 commit 2f0086e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ function isDeepSync (method, engine) {
114114
if (Array.isArray(method)) return method.every(i => isDeepSync(i, engine))
115115

116116
if (method && typeof method === 'object') {
117-
const func = Object.keys(method)[0]
117+
const keys = Object.keys(method)
118+
if (keys.length === 0) return true
119+
const func = keys[0]
118120

119121
const lower = method[func]
120122
if (!isSync(engine.methods[func])) return false

suites/plus.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,17 @@
182182
"rule": { "+": [[1]] },
183183
"result": { "error": "NaN" },
184184
"data": null
185+
},
186+
{
187+
"description": "Plus Operator with Single Operand, Object Input Produces NaN",
188+
"rule": { "+": [{}] },
189+
"result": { "error": "NaN" },
190+
"data": null
191+
},
192+
{
193+
"description": "Plus Operator with Single Operand, Direct Object Input Produces NaN",
194+
"rule": { "+": {} },
195+
"result": { "error": "NaN" },
196+
"data": null
185197
}
186198
]

0 commit comments

Comments
 (0)