Change unit conversion functions to operate on input rather than return a conversion factor (#6181)

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-04-08 14:21:23 +12:00
committed by GitHub
parent 6a5b23f848
commit 5b653fb558
39 changed files with 1551 additions and 1452 deletions

View File

@ -1534,8 +1534,8 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_default() {
let ast = r#"const inMm = 25.4 * mm()
const inInches = 1.0 * inch()"#;
let ast = r#"const inMm = fromMm(25.4)
const inInches = fromInches(1)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
25.4,
@ -1554,8 +1554,8 @@ const inInches = 1.0 * inch()"#;
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_overriden() {
let ast = r#"@settings(defaultLengthUnit = inch)
const inMm = 25.4 * mm()
const inInches = 1.0 * inch()"#;
const inMm = fromMm(25.4)
const inInches = fromInches(1)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
1.0,
@ -1575,8 +1575,8 @@ const inInches = 1.0 * inch()"#;
#[tokio::test(flavor = "multi_thread")]
async fn test_unit_overriden_in() {
let ast = r#"@settings(defaultLengthUnit = in)
const inMm = 25.4 * mm()
const inInches = 2.0 * inch()"#;
const inMm = fromMm(25.4)
const inInches = fromInches(2)"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
1.0,