Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mistress' into mistress
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyynthia committed Jan 23, 2024
2 parents 8fb3f07 + 5ccd1d1 commit 38fb814
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
Empty file modified LICENSE
100755 → 100644
Empty file.
24 changes: 3 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,15 @@ parser didn't feel too out of place.

*[insert xkcd 927]*

smol-toml passes most of the tests from [BurntSushi's `toml-test` suite](https://github.com/BurntSushi/toml-test).
However, due to the nature of JavaScript and the limits of the language, it doesn't pass certain tests, namely:
smol-toml passes most of the tests from the [`toml-test` suite](https://github.com/toml-lang/toml-test); use the
`run-toml-test.bash` script to run the tests. Due to the nature of JavaScript and the limits of the language,
it doesn't pass certain tests, namely:
- Invalid UTF-8 strings are not rejected
- Certain invalid UTF-8 codepoints are not rejected
- smol-toml doesn't preserve type information between integers and floats (in JS, everything is a float)
- smol-toml doesn't support the whole 64-bit range for integers (but does throw an appropriate error)
- As all numbers are floats in JS, the safe range is `2**53 - 1` <=> `-(2**53 - 1)`.

smol-toml also passes all of the tests in https://github.com/iarna/toml-spec-tests.

<details>
<summary>List of failed `toml-test` cases</summary>

These tests were done by modifying `primitive.ts` and make the implementation return bigints for integers. This allows
verifying the parser correctly intents a number to be an integer or a float.

*Ideally, this becomes an option of the library, but for now...*

The following parse tests are failing:
- invalid/encoding/bad-utf8-in-comment
- invalid/encoding/bad-utf8-in-multiline-literal
- invalid/encoding/bad-utf8-in-multiline
- invalid/encoding/bad-utf8-in-string-literal
- invalid/encoding/bad-utf8-in-string
- invalid/string/bad-codepoint
</details>

## Installation
```
[pnpm | yarn | npm] i smol-toml
Expand Down
20 changes: 20 additions & 0 deletions run-toml-test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Requires toml-test from https://github.com/toml-lang/toml-test, commit 78f8c61
# or newer (Oct 2023).

skip=(
# Invalid UTF-8 strings are not rejected
-skip='invalid/encoding/bad-utf8-*'

# Certain invalid UTF-8 codepoints are not rejected
-skip='invalid/encoding/bad-codepoint'

# JS uses floats for numbers
-skip='valid/integer/long'
)

e=0
toml-test -int-as-float ${skip[@]} ./toml-test-parse.js || e=1
toml-test -int-as-float -encoder ${skip[@]} ./toml-test-encode.js || e=1
exit $e
3 changes: 2 additions & 1 deletion toml-test-encode.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -26,7 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// Script for https://github.com/BurntSushi/toml-test
// Script for https://github.com/toml-lang/toml-test

import { TomlDate, stringify } from './dist/index.js'

Expand Down
3 changes: 2 additions & 1 deletion toml-test-parse.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -26,7 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// Script for https://github.com/BurntSushi/toml-test
// Script for https://github.com/toml-lang/toml-test

import { TomlDate, parse } from './dist/index.js'

Expand Down
Empty file modified tsconfig.json
100755 → 100644
Empty file.

0 comments on commit 38fb814

Please sign in to comment.