diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md index dae8c56..f567630 100644 --- a/README.md +++ b/README.md @@ -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. - -
-List of failed `toml-test` cases - -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 -
- ## Installation ``` [pnpm | yarn | npm] i smol-toml diff --git a/run-toml-test.bash b/run-toml-test.bash new file mode 100755 index 0000000..2dd13d7 --- /dev/null +++ b/run-toml-test.bash @@ -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 diff --git a/toml-test-encode.js b/toml-test-encode.js old mode 100644 new mode 100755 index 0467969..02e52c6 --- a/toml-test-encode.js +++ b/toml-test-encode.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node /*! * Copyright (c) Squirrel Chat et al., All rights reserved. * SPDX-License-Identifier: BSD-3-Clause @@ -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' diff --git a/toml-test-parse.js b/toml-test-parse.js old mode 100644 new mode 100755 index 288267b..c9da253 --- a/toml-test-parse.js +++ b/toml-test-parse.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node /*! * Copyright (c) Squirrel Chat et al., All rights reserved. * SPDX-License-Identifier: BSD-3-Clause @@ -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' diff --git a/tsconfig.json b/tsconfig.json old mode 100755 new mode 100644