From 202ca043ff792a5757f8b38bc9d391da73a28b5b Mon Sep 17 00:00:00 2001 From: ZHU Yuhao Date: Mon, 2 Mar 2026 22:19:59 +0100 Subject: [PATCH] =?UTF-8?q?tomlmojo=20=E2=86=92=20decimo.toml=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run_tests.yaml | 14 +-- README.md | 7 +- benches/decimal128/bench_comparison.mojo | 2 +- benches/decimal128/bench_quantize.mojo | 2 +- docs/plans/mojo4py.md | 20 ++-- docs/{readme_tomlmojo.md => readme_toml.md} | 52 +++++----- docs/readme_unreleased.md | 99 ++++++++++--------- docs/readme_zht.md | 2 +- pixi.toml | 13 +-- python/README.md | 14 +-- python/pyproject.toml | 52 +++++----- src/decimo/tests.mojo | 15 ++- src/{tomlmojo => decimo/toml}/__init__.mojo | 4 +- src/{tomlmojo => decimo/toml}/parser.mojo | 0 src/{tomlmojo => decimo/toml}/tokenizer.mojo | 0 .../test_bigdecimal_trigonometric.mojo | 3 +- .../test_decimal128_conversions.mojo | 2 +- tests/decimal128/test_decimal128_divide.mojo | 10 +- .../decimal128/test_decimal128_factorial.mojo | 2 +- .../decimal128/test_decimal128_from_int.mojo | 4 +- .../test_decimal128_from_string.mojo | 4 +- .../decimal128/test_decimal128_logarithm.mojo | 2 +- tests/decimal128/test_decimal128_modulo.mojo | 4 +- .../decimal128/test_decimal128_multiply.mojo | 4 +- .../test_decimal128_root_power.mojo | 2 +- tests/decimal128/test_decimal128_round.mojo | 8 +- tests/decimal128/test_decimal128_sqrt.mojo | 4 +- tests/test_all.sh | 2 +- tests/{test_tomlmojo.sh => test_toml.sh} | 2 +- .../test_decimo_toml.mojo} | 42 ++++---- 30 files changed, 193 insertions(+), 198 deletions(-) rename docs/{readme_tomlmojo.md => readme_toml.md} (80%) rename src/{tomlmojo => decimo/toml}/__init__.mojo (92%) rename src/{tomlmojo => decimo/toml}/parser.mojo (100%) rename src/{tomlmojo => decimo/toml}/tokenizer.mojo (100%) rename tests/{test_tomlmojo.sh => test_toml.sh} (67%) rename tests/{tomlmojo/test_tomlmojo.mojo => toml/test_decimo_toml.mojo} (93%) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index ac9ab59b..7b7fca08 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -35,7 +35,6 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests run: bash ./tests/test_bigdecimal.sh @@ -59,7 +58,6 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests run: bash ./tests/test_bigint.sh @@ -83,7 +81,6 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests run: bash ./tests/test_biguint.sh @@ -107,7 +104,6 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests run: bash ./tests/test_bigint10.sh @@ -131,13 +127,12 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests run: bash ./tests/test_decimal128.sh - # ── Test: TomlMojo ─────────────────────────────────────────────────────────── - test-tomlmojo: - name: Test TomlMojo + # ── Test: TOML parser ───────────────────────────────────────────────────── + test-toml: + name: Test TOML parser runs-on: ubuntu-22.04 timeout-minutes: 15 env: @@ -155,9 +150,8 @@ jobs: - name: Build packages run: | pixi run mojo package src/decimo && cp decimo.mojopkg tests/ - pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ - name: Run tests - run: bash ./tests/test_tomlmojo.sh + run: bash ./tests/test_toml.sh # ── Test: CLI ──────────────────────────────────────────────────────────────── test-cli: diff --git a/README.md b/README.md index 522c0abb..a083933c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Decimo provides an arbitrary-precision integer and decimal library for Mojo. It For Pythonistas, `decimo.BInt` to Mojo is like `int` to Python, and `decimo.Decimal` to Mojo is like `decimal.Decimal` to Python. -The core types are: +The core types are[^auxiliary]: - An arbitrary-precision signed integer type `BInt`[^bigint], which is a Mojo-native equivalent of Python's `int`. - An arbitrary-precision decimal implementation (`Decimal`) allowing for calculations with unlimited digits and decimal places[^arbitrary], which is a Mojo-native equivalent of Python's `decimal.Decimal`. @@ -40,15 +40,13 @@ The core types are: | `Decimal` | `BDec`, `BigDecimal` | Equivalent to Python's `decimal.Decimal` | Base-10^9 | | `Dec128` | `Decimal128` | 128-bit fixed-precision decimal type | Triple 32-bit words | -The auxiliary types include a base-10 arbitrary-precision signed integer type (`BigInt10`) and a base-10 arbitrary-precision unsigned integer type (`BigUInt`) supporting unlimited digits[^bigint10]. `BigUInt` is used as the internal representation for `BigInt10` and `Decimal`. - --- **Decimo** combines "**Deci**mal" and "**Mo**jo" - reflecting its purpose and implementation language. "Decimo" is also a Latin word meaning "tenth" and is the root of the word "decimal". --- -This repository includes [TOMLMojo](./docs/readme_tomlmojo.md), a lightweight TOML parser in pure Mojo. It parses configuration files and test data, supporting basic types, arrays, and nested tables. While created for Decimo's testing framework, it offers general-purpose structured data parsing with a clean, simple API. +This repository includes a built-in [TOML parser](./docs/readme_toml.md) (`decimo.toml`), a lightweight pure-Mojo implementation supporting TOML v1.0. It parses configuration files and test data, supporting basic types, arrays, and nested tables. While created for Decimo's testing framework, it offers general-purpose structured data parsing with a clean, simple API. ## Installation @@ -343,5 +341,6 @@ This repository and its contributions are licensed under the Apache License v2.0 [^fixed]: The `Decimal128` type can represent values with up to 29 significant digits and a maximum of 28 digits after the decimal point. When a value exceeds the maximum representable value (`2^96 - 1`), Decimo either raises an error or rounds the value to fit within these constraints. For example, the significant digits of `8.8888888888888888888888888888` (29 eights total with 28 after the decimal point) exceeds the maximum representable value (`2^96 - 1`) and is automatically rounded to `8.888888888888888888888888889` (28 eights total with 27 after the decimal point). Decimo's `Decimal128` type is similar to `System.Decimal` (C#/.NET), `rust_decimal` in Rust, `DECIMAL/NUMERIC` in SQL Server, etc. [^bigint]: The `BigInt` implementation uses a base-2^32 representation with a little-endian format, where the least significant word is stored at index 0. Each word is a `UInt32`, allowing for efficient storage and arithmetic operations on large integers. This design choice optimizes performance for binary computations while still supporting arbitrary precision. +[^auxiliary]: The auxiliary types include a base-10 arbitrary-precision signed integer type (`BigInt10`) and a base-10 arbitrary-precision unsigned integer type (`BigUInt`) supporting unlimited digits[^bigint10]. `BigUInt` is used as the internal representation for `BigInt10` and `Decimal`. [^bigint10]: The BigInt10 implementation uses a base-10 representation for users (maintaining decimal semantics), while internally using an optimized base-10^9 storage system for efficient calculations. This approach balances human-readable decimal operations with high-performance computing. It provides both floor division (round toward negative infinity) and truncate division (round toward zero) semantics, enabling precise handling of division operations with correct mathematical behavior regardless of operand signs. [^arbitrary]: Built on top of our completed BigInt10 implementation, BigDecimal will support arbitrary precision for both the integer and fractional parts, similar to `decimal` and `mpmath` in Python, `java.math.BigDecimal` in Java, etc. diff --git a/benches/decimal128/bench_comparison.mojo b/benches/decimal128/bench_comparison.mojo index 21d4af89..a815243a 100644 --- a/benches/decimal128/bench_comparison.mojo +++ b/benches/decimal128/bench_comparison.mojo @@ -25,7 +25,7 @@ fn main() raises: var pydecimal = Python.import_module("decimal") pydecimal.getcontext().prec = 28 - # --- TOML load via tomlmojo for 'op' field --- + # --- TOML load via decimo.toml for 'op' field --- var doc = parse_file("bench_data/comparison.toml") var cases_array = doc.get_array_of_tables("cases") var iterations = 10000 diff --git a/benches/decimal128/bench_quantize.mojo b/benches/decimal128/bench_quantize.mojo index ba2f92aa..2be050f0 100644 --- a/benches/decimal128/bench_quantize.mojo +++ b/benches/decimal128/bench_quantize.mojo @@ -51,7 +51,7 @@ fn main() raises: var pydecimal = Python.import_module("decimal") pydecimal.getcontext().prec = 28 - # --- TOML load via tomlmojo for 'rounding' field --- + # --- TOML load via decimo.toml for 'rounding' field --- var doc = parse_file("bench_data/quantize.toml") var cases_array = doc.get_array_of_tables("cases") var iterations = 10000 diff --git a/docs/plans/mojo4py.md b/docs/plans/mojo4py.md index 9ef4db5f..331111de 100644 --- a/docs/plans/mojo4py.md +++ b/docs/plans/mojo4py.md @@ -365,14 +365,20 @@ jobs: ```txt python/ - ├── decimo_module.mojo ← Mojo binding (builds to _decimo.so) - ├── _decimo.so ← compiled extension (PyInit__decimo, gitignored) - ├── decimo.py ← Python wrapper: Decimal class + BigDecimal alias + ├── pyproject.toml ← PyPI package config (hatchling, src layout) + ├── README.md ← PyPI landing page + ├── decimo_module.mojo ← Mojo binding (builds to src/decimo/_decimo.so) + ├── src/ + │ └── decimo/ + │ ├── __init__.py ← Python wrapper: Decimal class + BigDecimal alias + │ ├── _decimo.pyi ← Type stub for Pylance/mypy + │ ├── _decimo.so ← compiled extension (gitignored) + │ └── py.typed ← PEP 561 marker └── tests/ - └── test_decimo.py ← test script + └── test_decimo.py ← test script ``` -4. **Build command:** `pixi run pybuild` (= `mojo build python/decimo_module.mojo --emit shared-lib -I src -o python/_decimo.so`) +4. **Build command:** `pixi run buildpy` (= `mojo build python/decimo_module.mojo --emit shared-lib -I src -o python/src/decimo/_decimo.so`) 5. **`def_py_init` signature:** `fn(out self: T, args: PythonObject, kwargs: PythonObject) raises` — works as a free function, does not need to be a `@staticmethod` on the struct itself. This means **zero modifications to the core BigDecimal struct** are needed for the binding. @@ -447,8 +453,8 @@ jobs: Build and test with two commands: ```bash -pixi run pybuild # Compiles python/decimo_module.mojo → python/_decimo.so -pixi run pytest # Builds, then runs python/tests/test_decimo.py +pixi run buildpy # Compiles python/decimo_module.mojo → python/src/decimo/_decimo.so +pixi run testpy # Builds, then runs python/tests/test_decimo.py ``` From Python: diff --git a/docs/readme_tomlmojo.md b/docs/readme_toml.md similarity index 80% rename from docs/readme_tomlmojo.md rename to docs/readme_toml.md index b0c617cb..b8c5e7fc 100644 --- a/docs/readme_tomlmojo.md +++ b/docs/readme_toml.md @@ -1,8 +1,10 @@ -# TOMLMojo +# decimo.toml -A native TOML v1.0 parser for [Mojo](https://www.modular.com/mojo). +A native TOML v1.0 parser for [Mojo](https://www.modular.com/mojo), included as a subpackage of [Decimo](https://github.com/forfudan/decimo). -**[Repository on GitHub»](https://github.com/forfudan/decimo/tree/main/src/tomlmojo)** | **[Decimo»](https://github.com/forfudan/decimo)** +> Formerly distributed as the standalone package `tomlmojo`. Merged into Decimo as `decimo.toml` starting from v0.9.0. + +**[Source on GitHub»](https://github.com/forfudan/decimo/tree/main/src/decimo/toml)** | **[Decimo»](https://github.com/forfudan/decimo)** - [Overview](#overview) - [History](#history) @@ -24,30 +26,28 @@ A native TOML v1.0 parser for [Mojo](https://www.modular.com/mojo). ## Overview -TOMLMojo is a lightweight, pure-Mojo TOML parser (~1,500 LOC) that implements the core [TOML v1.0 specification](https://toml.io/en/v1.0.0). It parses TOML source text into a `TOMLDocument` — a nested dictionary structure that you can query by key, table name, or array index. It handles all common TOML constructs including nested tables, inline tables, dotted keys, arrays of tables, and all TOML data types. +`decimo.toml` (formerly TOMLMojo) is a lightweight, pure-Mojo TOML parser (~1,500 LOC) that implements the core [TOML v1.0 specification](https://toml.io/en/v1.0.0). It parses TOML source text into a `TOMLDocument` — a nested dictionary structure that you can query by key, table name, or array index. It handles all common TOML constructs including nested tables, inline tables, dotted keys, arrays of tables, and all TOML data types. ## History TOMLMojo was initially developed in **April 2025** alongside [Decimo](https://github.com/forfudan/decimo) v0.3.0 to support Decimo's TOML-based test data system. At that time, no TOML parser existed in the Mojo ecosystem, so I wrote one from scratch. -Currently, **Decimo heavily depends on TOMLMojo** for its entire testing and benchmarking infrastructure. All test cases and benchmark configurations are stored as TOML files and loaded via TOMLMojo's `parse_file()` API. - -While originally built for internal use, TOMLMojo has grown into a general-purpose TOML library suitable for any Mojo project that needs to parse configuration files or structured data. +Decimo heavily depends on this TOML parser for its entire testing and benchmarking infrastructure. All test cases and benchmark configurations are stored as TOML files and loaded via `parse_file()`. -The version number of TOMLMojo is aligned with the latest version of Decimo. +Starting from Decimo v0.9.0, TOMLMojo has been merged into the Decimo package as the `decimo.toml` subpackage to simplify dependency management and packaging. It is no longer distributed as a standalone conda package. ## Installation -TOMLMojo is available in the modular-community `https://repo.prefix.dev/modular-community` package repository. Add it to your `channels` in `pixi.toml`: +`decimo.toml` is included as part of the Decimo package. Install Decimo: -```toml -channels = ["https://conda.modular.com/max", "https://repo.prefix.dev/modular-community", "conda-forge"] +```bash +pixi add decimo ``` -Then install: +Then import the TOML parser: -```bash -pixi add tomlmojo +```mojo +from decimo.toml import parse_string, parse_file ``` ## Quick start @@ -55,10 +55,10 @@ pixi add tomlmojo ### Parse a TOML string ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_string(""" + var doc = parse_string(""" title = "My App" version = 42 debug = true @@ -86,10 +86,10 @@ fn main() raises: ### Parse a TOML file ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_file("config.toml") + var doc = parse_file("config.toml") var db = doc.get_table("database") print(db["name"].as_string()) # mydb ``` @@ -97,10 +97,10 @@ fn main() raises: ### Dotted keys and nested tables ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_string(""" + var doc = parse_string(""" fruit.name = "apple" fruit.color = "red" fruit.size.width = 10 @@ -129,10 +129,10 @@ fn main() raises: ### Inline tables ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_string(""" + var doc = parse_string(""" point = {x = 1, y = 2} animal = {type.name = "pug"} """) @@ -150,10 +150,10 @@ fn main() raises: ### Arrays and arrays of tables ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_string(""" + var doc = parse_string(""" colors = [ "red", "green", @@ -184,10 +184,10 @@ fn main() raises: ### Integer formats and special floats ```mojo -import tomlmojo +from decimo.toml import parse_string, parse_file fn main() raises: - var doc = tomlmojo.parse_string(""" + var doc = parse_string(""" hex = 0xDEADBEEF oct = 0o755 bin = 0b11010110 diff --git a/docs/readme_unreleased.md b/docs/readme_unreleased.md index 21c41ed1..5a921abc 100644 --- a/docs/readme_unreleased.md +++ b/docs/readme_unreleased.md @@ -2,17 +2,25 @@ An arbitrary-precision integer and decimal library for [Mojo](https://www.modular.com/mojo), inspired by Python's `int` and `Decimal`. -**[中文·漢字](https://github.com/forfudan/decimo/blob/main/docs/readme_zht.md)** | **[Changelog](https://github.com/forfudan/decimo/blob/main/docs/changelog.md)** | **[Repository on GitHub»](https://github.com/forfudan/decimo)** | **[Discord channel»](https://discord.gg/3rGH87uZTk)** - -- [Overview](#overview) -- [Project structure](#project-structure) -- [Installation](#installation) -- [Quick start](#quick-start) -- [Objective](#objective) -- [Status](#status) -- [Tests and benches](#tests-and-benches) -- [Citation](#citation) -- [License](#license) +[![Version](https://img.shields.io/github/v/tag/forfudan/decimo?label=version&color=blue)](https://github.com/forfudan/decimo/releases) +[![pixi](https://img.shields.io/badge/pixi%20add-decimo-purple)](https://prefix.dev/channels/modular-community/packages/decimo) +[![CI](https://img.shields.io/github/actions/workflow/status/forfudan/argmojo/run_tests.yaml?branch=main&label=tests)](https://github.com/forfudan/argmojo/actions/workflows/run_tests.yaml) +[![Last Commit](https://img.shields.io/github/last-commit/forfudan/argmojo?color=red)](https://github.com/forfudan/argmojo/commits/main) + + + + ## Overview @@ -38,7 +46,7 @@ The core types are[^auxiliary]: --- -Decimo also includes a command-line calculator application that supports arbitrary-precision calculations, powered by the `decimo` and `argmojo` libraries. +Decimo also includes **a command-line calculator application** that supports arbitrary-precision calculations, powered by [ArgMojo - a command-line argument parser library for Mojo](https://github.com/forfudan/argmojo). You can use it to evaluate complex mathematical expressions with high precision directly from your terminal. For example: @@ -48,40 +56,7 @@ You can use it to evaluate complex mathematical expressions with high precision --- -This repository includes [TOMLMojo](./docs/readme_tomlmojo.md), a lightweight TOML parser in pure Mojo. It parses configuration files and test data, supporting basic types, arrays, and nested tables. While created for Decimo's testing framework, it offers general-purpose structured data parsing with a clean, simple API. - -## Project structure - -```text -decimo/ -├── src/ # All source code -│ ├── decimo/ # Core library (mojo package) -│ │ ├── bigdecimal/ # Arbitrary-precision decimal (Decimal/BDec) -│ │ ├── bigint/ # Arbitrary-precision signed integer (BInt) -│ │ ├── bigint10/ # Base-10 signed integer (BigInt10) -│ │ ├── biguint/ # Base-10 unsigned integer (BigUInt) -│ │ ├── decimal128/ # 128-bit fixed-precision decimal (Dec128) -│ │ └── ... # Shared utilities (str, errors, rounding) -│ ├── tomlmojo/ # TOML parser library (mojo package) -│ └── cli/ # CLI calculator application -│ ├── main.mojo # Entry point (ArgMojo CLI) -│ └── calculator/ # Calculator engine (mojo package) -│ ├── tokenizer.mojo # Lexer: expression → tokens -│ ├── parser.mojo # Shunting-yard: infix → RPN -│ └── evaluator.mojo # RPN evaluator using BigDecimal -├── tests/ # Unit tests (one subfolder per module) -│ ├── bigdecimal/ -│ ├── bigint/ -│ ├── biguint/ -│ ├── decimal128/ -│ ├── cli/ # CLI calculator tests -│ └── tomlmojo/ -├── benches/ # Benchmarks (one subfolder per module) -├── docs/ # Documentation and design notes -└── pixi.toml # Project configuration and tasks -``` - -`src/decimo/` and `src/tomlmojo/` are Mojo packages — they are compiled with `mojo package` and can be imported by external projects. `src/cli/` is an application that consumes the `decimo` package and compiles to a standalone binary via `mojo build`. +Decimo also includes a built-in [TOML parser](./docs/readme_toml.md) (`decimo.toml`), a lightweight pure-Mojo implementation supporting TOML v1.0. It parses configuration files and test data, supporting basic types, arrays, and nested tables. While created for Decimo's testing framework, it offers general-purpose structured data parsing with a clean, simple API. ## Installation @@ -349,6 +324,38 @@ The `BInt` type is fully implemented and optimized. It has been benchmarked agai Bug reports and feature requests are welcome! If you encounter issues, please [file them here](https://github.com/forfudan/decimo/issues). +## Project structure + +```text +decimo/ +├── src/ # All source code +│ ├── decimo/ # Core library (mojo package) +│ │ ├── bigdecimal/ # Arbitrary-precision decimal (Decimal/BDec) +│ │ ├── bigint/ # Arbitrary-precision signed integer (BInt) +│ │ ├── bigint10/ # Base-10 signed integer (BigInt10) +│ │ ├── biguint/ # Base-10 unsigned integer (BigUInt) +│ │ ├── decimal128/ # 128-bit fixed-precision decimal (Dec128) +│ │ └── ... # Shared utilities (str, errors, rounding) +│ └── cli/ # CLI calculator application +│ ├── main.mojo # Entry point (ArgMojo CLI) +│ └── calculator/ # Calculator engine (mojo package) +│ ├── tokenizer.mojo # Lexer: expression → tokens +│ ├── parser.mojo # Shunting-yard: infix → RPN +│ └── evaluator.mojo # RPN evaluator using BigDecimal +├── tests/ # Unit tests (one subfolder per module) +│ ├── bigdecimal/ +│ ├── bigint/ +│ ├── biguint/ +│ ├── decimal128/ +│ ├── cli/ # CLI calculator tests +│ └── toml/ +├── benches/ # Benchmarks (one subfolder per module) +├── docs/ # Documentation and design notes +└── pixi.toml # Project configuration and tasks +``` + +`src/decimo/` is a Mojo package — it is compiled with `mojo package` and can be imported by external projects. The TOML parser (`decimo.toml`) is included as a subpackage. `src/cli/` is an application that consumes the `decimo` package and compiles to a standalone binary via `mojo build`. + ## Tests and benches After cloning the repo onto your local disk, you can: diff --git a/docs/readme_zht.md b/docs/readme_zht.md index 77c7e78f..72ca4865 100644 --- a/docs/readme_zht.md +++ b/docs/readme_zht.md @@ -42,7 +42,7 @@ Decimo 是 Decimal 和 Mojo 的組合,既反映了它的目的,也反應了 --- -此倉庫包含 [TOMLMojo](./docs/readme_tomlmojo.md),一個純 Mojo 實現的輕量級 TOML 解析器。它解析配置文件和測試數據,支持基本類型、數組和嵌套表。雖然爲 Decimo 的測試框架而創建,但它提供通用的結構化數據解析,具有簡潔的 API。 +此倉庫包含內建的 [TOML 解析器](./docs/readme_toml.md)(`decimo.toml`),一個純 Mojo 實現的輕量級 TOML v1.0 解析器。它解析配置文件和測試數據,支持基本類型、數組和嵌套表。雖然爲 Decimo 的測試框架而創建,但它提供通用的結構化數據解析,具有簡潔的 API。 ## 安裝 diff --git a/pixi.toml b/pixi.toml index 808a12ab..effb9b0c 100644 --- a/pixi.toml +++ b/pixi.toml @@ -32,30 +32,23 @@ doc = """clear && pixi run mojo doc \ # compile the package p = "clear && pixi run package" package = """pixi run format \ -&& pixi run package_decimo \ -&& pixi run package_tomlmojo""" +&& pixi run package_decimo""" package_decimo = """pixi run mojo package src/decimo \ && cp decimo.mojopkg tests/ \ && cp decimo.mojopkg benches/ \ && rm decimo.mojopkg""" -package_tomlmojo = """pixi run mojo package src/tomlmojo \ -&& cp tomlmojo.mojopkg tests/ \ -&& cp tomlmojo.mojopkg benches/ \ -&& rm tomlmojo.mojopkg""" # clean the package files in tests folder c = "clear && pixi run clean" clean = """rm tests/decimo.mojopkg && \ -rm benches/decimo.mojopkg && \ -rm tests/tomlmojo.mojopkg && \ -rm benches/tomlmojo.mojopkg""" +rm benches/decimo.mojopkg""" # tests (use the mojo testing tool) t = "clear && pixi run test" tdecimo = "clear && pixi run testdecimo" test = "pixi run package && bash ./tests/test_all.sh" testdecimo = "pixi run package && bash ./tests/test_decimo.sh" -testtoml = "pixi run package && bash ./tests/test_tomlmojo.sh" +testtoml = "pixi run package && bash ./tests/test_toml.sh" ttoml = "clear && pixi run testtoml" # bench diff --git a/python/README.md b/python/README.md index 2677b71c..a2f008dc 100644 --- a/python/README.md +++ b/python/README.md @@ -30,13 +30,13 @@ print(a / b) # 0.12499999... ## Status -| Feature | Status | -|---|---| -| `Decimal` (BigDecimal) arithmetic (`+`, `-`, `*`, `/`) | ✅ Working | -| Comparison operators | ✅ Working | -| Unary `-`, `abs()`, `bool()` | ✅ Working | -| Pre-built wheels on PyPI | 🚧 Coming soon | -| `BigInt` / `Decimal128` Python bindings | 🔜 Planned | +| Feature | Status | +| ------------------------------------------------------ | ------------- | +| `Decimal` (BigDecimal) arithmetic (`+`, `-`, `*`, `/`) | ✓ Working | +| Comparison operators | ✓ Working | +| Unary `-`, `abs()`, `bool()` | ✓ Working | +| Pre-built wheels on PyPI | ? Coming soon | +| `BigInt` / `Decimal128` Python bindings | ? Planned | ## Building from source diff --git a/python/pyproject.toml b/python/pyproject.toml index d86ffd8c..41f6cd9e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,40 +1,40 @@ [build-system] -requires = ["hatchling"] build-backend = "hatchling.build" +requires = ["hatchling"] [tool.hatch.build.targets.wheel] packages = ["src/decimo"] [project] +authors = [{name = "ZHU Yuhao (朱宇浩)", email = "dr.yuhao.zhu@outlook.com"}] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Scientific/Engineering :: Mathematics", + "Typing :: Typed", +] +description = "Arbitrary-precision decimal arithmetic for Python, powered by Mojo" +keywords = [ + "decimal", + "arbitrary-precision", + "mojo", + "bigdecimal", + "arithmetic", + "numeric", +] +license = {text = "Apache-2.0"} name = "decimo" -version = "0.1.0.dev0" -description = "Arbitrary-precision decimal and integer arithmetic for Python, powered by Mojo" readme = "README.md" -license = { text = "Apache-2.0" } -authors = [{ name = "ZHU Yuhao (朱宇浩)", email = "dr.yuhao.zhu@outlook.com" }] requires-python = ">=3.11" -keywords = [ - "decimal", - "arbitrary-precision", - "mojo", - "bigdecimal", - "arithmetic", - "numeric", -] -classifiers = [ - "Development Status :: 2 - Pre-Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Topic :: Scientific/Engineering :: Mathematics", - "Typing :: Typed", -] +version = "0.1.0.dev0" [project.urls] +Changelog = "https://github.com/forfudan/decimo/blob/main/docs/changelog.md" Homepage = "https://github.com/forfudan/decimo" -Repository = "https://github.com/forfudan/decimo" Issues = "https://github.com/forfudan/decimo/issues" -Changelog = "https://github.com/forfudan/decimo/blob/main/docs/changelog.md" +Repository = "https://github.com/forfudan/decimo" diff --git a/src/decimo/tests.mojo b/src/decimo/tests.mojo index f9f8666a..1216bff0 100644 --- a/src/decimo/tests.mojo +++ b/src/decimo/tests.mojo @@ -18,7 +18,7 @@ Shared infrastructure for Decimo tests and benchmarks. Provides: -- Test case and benchmark case loading from TOML files (via tomlmojo) +- Test case and benchmark case loading from TOML files (via decimo.toml) - Pattern expansion: {C,N} repeats string C exactly N times - Log file management and formatted output (console + log) - Summary statistics reporting for benchmarks @@ -50,7 +50,8 @@ Pattern expansion in string values: "{123456789,5}" → "123456789" repeated 5 times """ -import tomlmojo +from .toml import parse_file as parse_toml_file +from .toml.parser import TOMLDocument from python import Python, PythonObject from collections import List import os @@ -247,10 +248,10 @@ fn expand_value(s: String) raises -> String: # ===----------------------------------------------------------------------=== # -fn parse_file(file_path: String) raises -> tomlmojo.parser.TOMLDocument: +fn parse_file(file_path: String) raises -> TOMLDocument: """Parse a TOML file and return the TOMLDocument.""" try: - return tomlmojo.parse_file(file_path) + return parse_toml_file(file_path) except e: raise Error( "tests.parse_file(): Failed to parse TOML file:", @@ -262,9 +263,7 @@ fn parse_file(file_path: String) raises -> tomlmojo.parser.TOMLDocument: fn load_test_cases[ unary: Bool = False -](toml: tomlmojo.parser.TOMLDocument, table_name: String) raises -> List[ - TestCase -]: +](toml: TOMLDocument, table_name: String) raises -> List[TestCase]: """Load test cases from a TOMLDocument. String values are expanded using the {C,N} pattern syntax. @@ -309,7 +308,7 @@ fn load_test_cases[ fn load_bench_cases(toml_path: String) raises -> List[BenchCase]: """Load benchmark cases from a TOML file. - Uses tomlmojo to parse the TOML file. Operand values are expanded + Uses decimo.toml to parse the TOML file. Operand values are expanded using the {C,N} pattern syntax. Args: diff --git a/src/tomlmojo/__init__.mojo b/src/decimo/toml/__init__.mojo similarity index 92% rename from src/tomlmojo/__init__.mojo rename to src/decimo/toml/__init__.mojo index 134ebae5..7e47d883 100644 --- a/src/tomlmojo/__init__.mojo +++ b/src/decimo/toml/__init__.mojo @@ -15,7 +15,9 @@ # ===----------------------------------------------------------------------=== # """ -tomlmojo — A native TOML v1.0 parser for Mojo. +decimo.toml — A native TOML v1.0 parser for Mojo. + +(Originally named tomlmojo, now merged into decimo as a subpackage.) Supports: - Basic and literal strings (single-line and multi-line) diff --git a/src/tomlmojo/parser.mojo b/src/decimo/toml/parser.mojo similarity index 100% rename from src/tomlmojo/parser.mojo rename to src/decimo/toml/parser.mojo diff --git a/src/tomlmojo/tokenizer.mojo b/src/decimo/toml/tokenizer.mojo similarity index 100% rename from src/tomlmojo/tokenizer.mojo rename to src/decimo/toml/tokenizer.mojo diff --git a/tests/bigdecimal/test_bigdecimal_trigonometric.mojo b/tests/bigdecimal/test_bigdecimal_trigonometric.mojo index 356c2082..0f8dddbe 100644 --- a/tests/bigdecimal/test_bigdecimal_trigonometric.mojo +++ b/tests/bigdecimal/test_bigdecimal_trigonometric.mojo @@ -7,13 +7,14 @@ import testing from decimo import BDec from decimo.tests import TestCase, parse_file, load_test_cases +from decimo.toml.parser import TOMLDocument comptime file_path = "tests/bigdecimal/test_data/bigdecimal_trigonometric.toml" fn run_test[ func: fn (BDec, Int) raises -> BDec -](toml: tomlmojo.parser.TOMLDocument, table_name: String, msg: String) raises: +](toml: TOMLDocument, table_name: String, msg: String) raises: """Run a specific test case from the TOML document.""" # print("------------------------------------------------------") # print("Testing BigDecimal ", msg, "...", sep="") diff --git a/tests/decimal128/test_decimal128_conversions.mojo b/tests/decimal128/test_decimal128_conversions.mojo index 312806cb..dd929a40 100644 --- a/tests/decimal128/test_decimal128_conversions.mojo +++ b/tests/decimal128/test_decimal128_conversions.mojo @@ -4,7 +4,7 @@ Merges former to_string, to_int, to_float test files. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo import Dec128 from decimo import Decimal128 diff --git a/tests/decimal128/test_decimal128_divide.mojo b/tests/decimal128/test_decimal128_divide.mojo index 9591a0ff..ec5f828e 100644 --- a/tests/decimal128/test_decimal128_divide.mojo +++ b/tests/decimal128/test_decimal128_divide.mojo @@ -8,7 +8,7 @@ mathematical relationship verification. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo import Decimal128, RoundingMode from decimo.tests import parse_file, load_test_cases @@ -19,9 +19,7 @@ comptime data_path = "tests/decimal128/test_data/decimal128_divide.toml" # ─── TOML-driven helpers ──────────────────────────────────────────────────── -fn _run_division_section( - doc: tomlmojo.parser.TOMLDocument, section: String -) raises: +fn _run_division_section(doc: TOMLDocument, section: String) raises: """Run division (/) test cases from a TOML section.""" var cases = load_test_cases(doc, section) for tc in cases: @@ -29,9 +27,7 @@ fn _run_division_section( testing.assert_equal(String(result), tc.expected, tc.description) -fn _run_truncate_section( - doc: tomlmojo.parser.TOMLDocument, section: String -) raises: +fn _run_truncate_section(doc: TOMLDocument, section: String) raises: """Run truncate division (//) test cases from a TOML section.""" var cases = load_test_cases(doc, section) for tc in cases: diff --git a/tests/decimal128/test_decimal128_factorial.mojo b/tests/decimal128/test_decimal128_factorial.mojo index 43a13648..e56deefb 100644 --- a/tests/decimal128/test_decimal128_factorial.mojo +++ b/tests/decimal128/test_decimal128_factorial.mojo @@ -5,7 +5,7 @@ edge cases, and reciprocal tests. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode diff --git a/tests/decimal128/test_decimal128_from_int.mojo b/tests/decimal128/test_decimal128_from_int.mojo index f37528ac..18602bca 100644 --- a/tests/decimal128/test_decimal128_from_int.mojo +++ b/tests/decimal128/test_decimal128_from_int.mojo @@ -13,7 +13,7 @@ Test Decimal128.from_int() and Decimal128 component constructor including: """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo import Dec128 from decimo import Decimal128 @@ -23,7 +23,7 @@ comptime file_path = "tests/decimal128/test_data/decimal128_from_int.toml" fn _run_from_int_section( - toml: tomlmojo.parser.TOMLDocument, + toml: TOMLDocument, section: String, mut count_wrong: Int, ) raises: diff --git a/tests/decimal128/test_decimal128_from_string.mojo b/tests/decimal128/test_decimal128_from_string.mojo index 160fb74e..2af2f731 100644 --- a/tests/decimal128/test_decimal128_from_string.mojo +++ b/tests/decimal128/test_decimal128_from_string.mojo @@ -14,7 +14,7 @@ Test Decimal128.from_string() constructor including: """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo import Dec128 from decimo.tests import TestCase, parse_file, load_test_cases @@ -23,7 +23,7 @@ comptime file_path = "tests/decimal128/test_data/decimal128_from_string.toml" fn _run_unary_section( - toml: tomlmojo.parser.TOMLDocument, + toml: TOMLDocument, section: String, mut count_wrong: Int, ) raises: diff --git a/tests/decimal128/test_decimal128_logarithm.mojo b/tests/decimal128/test_decimal128_logarithm.mojo index cf2a1cab..9012d40f 100644 --- a/tests/decimal128/test_decimal128_logarithm.mojo +++ b/tests/decimal128/test_decimal128_logarithm.mojo @@ -6,7 +6,7 @@ tolerance, exception, and mathematical property tests. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode diff --git a/tests/decimal128/test_decimal128_modulo.mojo b/tests/decimal128/test_decimal128_modulo.mojo index 89f7f9d6..8f1c2ad7 100644 --- a/tests/decimal128/test_decimal128_modulo.mojo +++ b/tests/decimal128/test_decimal128_modulo.mojo @@ -6,7 +6,7 @@ and consistency with floor division. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode @@ -15,7 +15,7 @@ from decimo.tests import parse_file, load_test_cases comptime data_path = "tests/decimal128/test_data/decimal128_modulo.toml" -fn _run_section(doc: tomlmojo.parser.TOMLDocument, section: String) raises: +fn _run_section(doc: TOMLDocument, section: String) raises: """Run modulo test cases from a TOML section.""" var cases = load_test_cases(doc, section) for tc in cases: diff --git a/tests/decimal128/test_decimal128_multiply.mojo b/tests/decimal128/test_decimal128_multiply.mojo index c7fd1628..cc07fb26 100644 --- a/tests/decimal128/test_decimal128_multiply.mojo +++ b/tests/decimal128/test_decimal128_multiply.mojo @@ -11,7 +11,7 @@ Test Decimal128 multiplication operations including: from python import Python, PythonObject import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo import Dec128 from decimo import Decimal128 @@ -21,7 +21,7 @@ comptime file_path = "tests/decimal128/test_data/decimal128_multiply.toml" fn _run_multiply_section( - toml: tomlmojo.parser.TOMLDocument, + toml: TOMLDocument, pydecimal: PythonObject, section: String, mut count_wrong: Int, diff --git a/tests/decimal128/test_decimal128_root_power.mojo b/tests/decimal128/test_decimal128_root_power.mojo index 5802347e..50da50ce 100644 --- a/tests/decimal128/test_decimal128_root_power.mojo +++ b/tests/decimal128/test_decimal128_root_power.mojo @@ -6,7 +6,7 @@ tolerance, exception, and mathematical property tests. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode diff --git a/tests/decimal128/test_decimal128_round.mojo b/tests/decimal128/test_decimal128_round.mojo index be180e7a..a385bea8 100644 --- a/tests/decimal128/test_decimal128_round.mojo +++ b/tests/decimal128/test_decimal128_round.mojo @@ -4,7 +4,7 @@ TOML-driven tests for standard cases; inline for dynamic/consistency tests. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode @@ -14,7 +14,7 @@ comptime data_path = "tests/decimal128/test_data/decimal128_round.toml" fn _run_round_section( - doc: tomlmojo.parser.TOMLDocument, + doc: TOMLDocument, section: String, mode: RoundingMode, ) raises: @@ -25,9 +25,7 @@ fn _run_round_section( testing.assert_equal(String(result), tc.expected, tc.description) -fn _run_round_default_section( - doc: tomlmojo.parser.TOMLDocument, section: String -) raises: +fn _run_round_default_section(doc: TOMLDocument, section: String) raises: """Run round test cases using builtin round() (banker's rounding).""" var cases = load_test_cases(doc, section) for tc in cases: diff --git a/tests/decimal128/test_decimal128_sqrt.mojo b/tests/decimal128/test_decimal128_sqrt.mojo index f3637d2e..37d987ac 100644 --- a/tests/decimal128/test_decimal128_sqrt.mojo +++ b/tests/decimal128/test_decimal128_sqrt.mojo @@ -5,7 +5,7 @@ inline for startswith, tolerance, identity, and exception tests. """ import testing -import tomlmojo +from decimo.toml.parser import TOMLDocument from decimo.decimal128.decimal128 import Decimal128, Dec128 from decimo.rounding_mode import RoundingMode @@ -17,7 +17,7 @@ comptime data_path = "tests/decimal128/test_data/decimal128_sqrt.toml" # ─── helpers ───────────────────────────────────────────────────────────────── -fn _run_sqrt_section(doc: tomlmojo.parser.TOMLDocument, section: String) raises: +fn _run_sqrt_section(doc: TOMLDocument, section: String) raises: var cases = load_test_cases[unary=True](doc, section) for tc in cases: var result = Dec128(tc.a).sqrt() diff --git a/tests/test_all.sh b/tests/test_all.sh index c6864869..eca805af 100644 --- a/tests/test_all.sh +++ b/tests/test_all.sh @@ -2,5 +2,5 @@ set -e bash ./tests/test_decimo.sh -bash ./tests/test_tomlmojo.sh +bash ./tests/test_toml.sh bash ./tests/test_cli.sh diff --git a/tests/test_tomlmojo.sh b/tests/test_toml.sh similarity index 67% rename from tests/test_tomlmojo.sh rename to tests/test_toml.sh index ada89a54..aef15bde 100755 --- a/tests/test_tomlmojo.sh +++ b/tests/test_toml.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -for f in tests/tomlmojo/*.mojo; do +for f in tests/toml/*.mojo; do pixi run mojo run -I src -D ASSERT=all "$f" done diff --git a/tests/tomlmojo/test_tomlmojo.mojo b/tests/toml/test_decimo_toml.mojo similarity index 93% rename from tests/tomlmojo/test_tomlmojo.mojo rename to tests/toml/test_decimo_toml.mojo index e3855466..2d62e3cb 100644 --- a/tests/tomlmojo/test_tomlmojo.mojo +++ b/tests/toml/test_decimo_toml.mojo @@ -1,6 +1,6 @@ -"""Comprehensive test suite for tomlmojo — covers all newly added TOML features.""" +"""Comprehensive test suite for decimo.toml — covers all TOML features.""" -import tomlmojo +from decimo.toml import parse_string, parse_file import testing @@ -12,7 +12,7 @@ fn main() raises: # 1. Basic key-value pairs # --------------------------------------------------------------------------- fn test_basic_key_value() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ title = "TOML Example" count = 42 @@ -30,7 +30,7 @@ enabled = true # 2. Standard tables # --------------------------------------------------------------------------- fn test_table() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ [server] host = "localhost" @@ -47,7 +47,7 @@ port = 1018 # 3. Simple array # --------------------------------------------------------------------------- fn test_array() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ colors = ["red", "green", "blue"] numbers = [1, 2, 3] @@ -64,7 +64,7 @@ numbers = [1, 2, 3] # 4. Multiline array with trailing comma & comments # --------------------------------------------------------------------------- fn test_multiline_array() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ fruits = [ "apple", @@ -83,7 +83,7 @@ fruits = [ # 5. Dotted keys # --------------------------------------------------------------------------- fn test_dotted_keys() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ fruit.name = "apple" fruit.color = "red" @@ -107,7 +107,7 @@ fruit.size.height = 20 # 6. Dotted table headers # --------------------------------------------------------------------------- fn test_dotted_table_headers() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ [a.b.c] key = "value" @@ -127,7 +127,7 @@ key = "value" # 7. Quoted keys # --------------------------------------------------------------------------- fn test_quoted_keys() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ "my key" = "value1" 'bare-literal' = "value2" @@ -141,7 +141,7 @@ fn test_quoted_keys() raises: # 8. Inline tables # --------------------------------------------------------------------------- fn test_inline_table() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ point = {x = 1, y = 2} """ @@ -158,7 +158,7 @@ point = {x = 1, y = 2} # 9. Nested inline tables # --------------------------------------------------------------------------- fn test_inline_table_nested() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ animal = {type.name = "cat"} """ @@ -173,7 +173,7 @@ animal = {type.name = "cat"} # 10. Array of tables # --------------------------------------------------------------------------- fn test_array_of_tables() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ [[products]] name = "Hammer" @@ -195,7 +195,7 @@ sku = 284758393 # 11. Array of tables with dotted header # --------------------------------------------------------------------------- fn test_array_of_tables_dotted() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ [[fruits]] name = "apple" @@ -215,7 +215,7 @@ name = "banana" # 12. Unicode escape sequences # --------------------------------------------------------------------------- fn test_unicode_escapes() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ smile = "\\u0041" """ @@ -229,7 +229,7 @@ smile = "\\u0041" # 13. Integer bases: hex, octal, binary # --------------------------------------------------------------------------- fn test_integer_bases() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ hex = 0xDEADBEEF oct = 0o755 @@ -248,7 +248,7 @@ dec = 1_000_000 # 14. Special float values (inf, nan) # --------------------------------------------------------------------------- fn test_special_floats() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ pos_inf = inf neg_inf = -inf @@ -265,7 +265,7 @@ not_a_number = nan # --------------------------------------------------------------------------- fn test_multiline_strings() raises: var src = String('[test]\nml = """line1\nline2\nline3"""\n') - var doc = tomlmojo.parse_string(src) + var doc = parse_string(src) var tbl = doc.get_table("test") var ml = tbl["ml"].as_string() # The multiline string should contain the newlines @@ -277,7 +277,7 @@ fn test_multiline_strings() raises: # 16. Nested tables via dotted keys + standard tables # --------------------------------------------------------------------------- fn test_nested_tables_via_dotted() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ [server] host = "localhost" @@ -303,7 +303,7 @@ port = 1314 fn test_duplicate_key_detection() raises: var caught = False try: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ name = "first" name = "second" @@ -319,7 +319,7 @@ name = "second" # 18. Mixed features # --------------------------------------------------------------------------- fn test_mixed_features() raises: - var doc = tomlmojo.parse_string( + var doc = parse_string( """ title = "Mixed Test" @@ -364,7 +364,7 @@ role = "backend" # 19. Parse our actual pixi.toml to make sure it still works # --------------------------------------------------------------------------- fn test_our_pixi_toml() raises: - var doc = tomlmojo.parse_file("pixi.toml") + var doc = parse_file("pixi.toml") var ws = doc.get_table("workspace") assert_true(len(ws) > 0, "pixi.toml workspace table non-empty") assert_true(ws["name"].as_string() == "decimo", "pixi.toml name")