Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor fixtures for serde tests #236

Closed
wants to merge 3 commits into from
Closed
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
49 changes: 0 additions & 49 deletions test/fixtures/serde-test-cases/deserialization.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/fixtures/serde-test-cases/deserialization/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = [
{
name: 'sparse array',
value: [1, undefined, 3],
serialized: '[1,,3]'
}
];
8 changes: 8 additions & 0 deletions test/fixtures/serde-test-cases/deserialization/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = [].concat(
require('./number'),
require('./string'),
require('./array'),
require('./object')
);
24 changes: 24 additions & 0 deletions test/fixtures/serde-test-cases/deserialization/number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

module.exports = [
{
name: 'binary numbers',
value: 10,
serialized: '0b1010'
},
{
name: 'octal numbers',
value: 83,
serialized: '0o123'
},
{
name: 'hexadecimal numbers',
value: 0xff,
serialized: '0xff'
},
{
name: 'hexadecimal numbers in upper case',
value: 0xAF,
serialized: '0xAF'
}
];
19 changes: 19 additions & 0 deletions test/fixtures/serde-test-cases/deserialization/object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

module.exports = [
{
name: 'object with whitespaces',
value: { key: 42 },
serialized: '{ key:\n\t42 }'
},
{
name: 'object with single-quoted keys',
value: { key: 42 },
serialized: '{\'key\': 42}'
},
{
name: 'object with double-quoted keys',
value: { key: 42 },
serialized: '{"key": 42}'
}
];
9 changes: 9 additions & 0 deletions test/fixtures/serde-test-cases/deserialization/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = [
{
name: 'Unicode code point escapes',
value: '💚💛',
serialized: '\'\\u{1F49A}\\u{1F49B}\''
}
];
2 changes: 1 addition & 1 deletion test/fixtures/serde-test-cases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
serde: require('./serde'),
serialization: require('./serialization'),
deserialization: require('./deserialization'),
invalidDeserialization: require('./deserialization-invalid')
invalid: require('./invalid')
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = [
value: '\'\\u{\''
},
{
name: 'illegal input $6',
name: 'illegal input #6',
value: '\'\\u{}\''
},
{
Expand Down
141 changes: 0 additions & 141 deletions test/fixtures/serde-test-cases/serde.js

This file was deleted.

42 changes: 42 additions & 0 deletions test/fixtures/serde-test-cases/serde/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

module.exports = [
{
name: 'empty array',
value: [],
serialized: '[]'
},
{
name: 'array of integers',
value: [1, 2, 3],
serialized: '[1,2,3]'
},
{
name: 'nested arrays',
value: ['outer', ['inner']],
serialized: '[\'outer\',[\'inner\']]'
},
{
name: 'Marcus array',
value: [
'Marcus Aurelius',
'AE127095',
[
'1990-02-15T00:00:00.000Z',
'Rome'
],
[
'Ukraine',
'Kiev',
'03056',
'Pobedy',
'37',
'1',
'158'
]
],
serialized: '[\'Marcus Aurelius\',\'AE127095\',' +
'[\'1990-02-15T00:00:00.000Z\',\'Rome\'],' +
'[\'Ukraine\',\'Kiev\',\'03056\',\'Pobedy\',\'37\',\'1\',\'158\']]'
}
];
14 changes: 14 additions & 0 deletions test/fixtures/serde-test-cases/serde/boolean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = [
{
name: 'true',
value: true,
serialized: 'true'
},
{
name: 'false',
value: false,
serialized: 'false'
}
];
11 changes: 11 additions & 0 deletions test/fixtures/serde-test-cases/serde/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = [].concat(
require('./boolean'),
require('./number'),
require('./string'),
require('./null'),
require('./undefined'),
require('./array'),
require('./object')
);
9 changes: 9 additions & 0 deletions test/fixtures/serde-test-cases/serde/null.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = [
{
name: 'null',
value: null,
serialized: 'null'
}
];
29 changes: 29 additions & 0 deletions test/fixtures/serde-test-cases/serde/number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

module.exports = [
{
name: 'integer',
value: 42,
serialized: '42'
},
{
name: 'negative integer',
value: -3,
serialized: '-3'
},
{
name: 'float',
value: 1e100,
serialized: '1e+100'
},
{
name: 'float with comma',
value: 3.14,
serialized: '3.14'
},
{
name: 'small float',
value: 1e-3,
serialized: '0.001'
}
];
Loading