better testing + bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-01-11 04:47:53 +03:00
parent 0feee69ee9
commit 047d80f792
3 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-serialize", "name": "ig-serialize",
"version": "1.0.5", "version": "1.0.6",
"description": "experimental extended json serializaion...", "description": "experimental extended json serializaion...",
"main": "serialize.js", "main": "serialize.js",
"scripts": { "scripts": {

View File

@ -413,7 +413,7 @@ module.eJSON = {
var mode = 'dec' var mode = 'dec'
if(str[j] == '0' if(str[j] == '0'
&& 'xXbBoO'.includes(str[j+1])){ && 'xXbBoO'.includes(str[j+1])){
mode = str[j+1] mode = str[j+1].toLowerCase()
j++ } j++ }
j++ j++
while(j < str.length while(j < str.length
@ -432,6 +432,7 @@ module.eJSON = {
// exponent... // exponent...
|| str[j] == 'e' || str[j] == 'e'
|| str[j] == 'E')){ || str[j] == 'E')){
// exponent sign...
if('eE'.includes(str[j]) if('eE'.includes(str[j])
&& '+-'.includes(str[j+1])){ && '+-'.includes(str[j+1])){
j++ } j++ }

View File

@ -49,6 +49,8 @@ var setups = test.Setups({
// return ['+123', json] }, // return ['+123', json] },
'number-exp': function(assert){ 'number-exp': function(assert){
return ['1e+100', json] }, return ['1e+100', json] },
'number-exp-neg': function(assert){
return ['1e-100', json] },
'number-zero': function(assert){ 'number-zero': function(assert){
return ['0', json] }, return ['0', json] },
'float-a': function(assert){ 'float-a': function(assert){
@ -204,9 +206,16 @@ test.Cases({
['123.', '123'], ['123.', '123'],
['+123', '123'], ['+123', '123'],
['123e100', '123e+100'], ['123e100', '123e+100'],
['123E100', '123e+100'],
['0xff', '255'], ['0xff', '255'],
['0Xff', '255'],
['0o77', '63'],
['0O77', '63'],
['0b11', '3'],
['0B11', '3'],
// string quotes... // string quotes...
// XXX test new lines...
["'abc'", '"abc"'], ["'abc'", '"abc"'],
['`abc`', '"abc"'], ['`abc`', '"abc"'],