Remove deprecated syntax (#6561)

* Remove deprecated syntax

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* fix one test

* fix sketch on revolved face test

* fix test: empty-scene default-planes act as expected

* fix up more tests

* another fix

* remove another const

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
Nick Cameron
2025-04-30 13:12:40 +12:00
committed by GitHub
parent 29b8a442c2
commit 0ea0d1703e
127 changed files with 2092 additions and 2359 deletions

View File

@ -1269,16 +1269,16 @@ mod tests {
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_fn_definitions() {
let ast = r#"fn def = (x) => {
let ast = r#"fn def(x) {
return x
}
fn ghi = (x) => {
fn ghi(x) {
return x
}
fn jkl = (x) => {
fn jkl(x) {
return x
}
fn hmm = (x) => {
fn hmm(x) {
return x
}
@ -1302,8 +1302,8 @@ yo2 = hmm([identifierGuy + 5])"#;
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_pipe_substitutions_unary() {
let ast = r#"const myVar = 3
const part001 = startSketchOn(XY)
let ast = r#"myVar = 3
part001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [3, 4], tag = $seg01)
|> line(end = [
@ -1317,8 +1317,8 @@ const part001 = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_pipe_substitutions() {
let ast = r#"const myVar = 3
const part001 = startSketchOn(XY)
let ast = r#"myVar = 3
part001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> line(end = [3, 4], tag = $seg01)
|> line(end = [
@ -1332,21 +1332,21 @@ const part001 = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_inline_comment() {
let ast = r#"const baseThick = 1
const armAngle = 60
let ast = r#"baseThick = 1
armAngle = 60
const baseThickHalf = baseThick / 2
const halfArmAngle = armAngle / 2
baseThickHalf = baseThick / 2
halfArmAngle = armAngle / 2
const arrExpShouldNotBeIncluded = [1, 2, 3]
const objExpShouldNotBeIncluded = { a: 1, b: 2, c: 3 }
arrExpShouldNotBeIncluded = [1, 2, 3]
objExpShouldNotBeIncluded = { a = 1, b = 2, c = 3 }
const part001 = startSketchOn(XY)
part001 = startSketchOn(XY)
|> startProfile(at = [0, 0])
|> yLine(endAbsolute = 1)
|> xLine(length = 3.84) // selection-range-7ish-before-this
const variableBelowShouldNotBeIncluded = 3
variableBelowShouldNotBeIncluded = 3
"#;
parse_execute(ast).await.unwrap();
@ -1354,15 +1354,15 @@ const variableBelowShouldNotBeIncluded = 3
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_function_literal_in_pipe() {
let ast = r#"const w = 20
const l = 8
const h = 10
let ast = r#"w = 20
l = 8
h = 10
fn thing = () => {
fn thing() {
return -8
}
const firstExtrude = startSketchOn(XY)
firstExtrude = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1375,15 +1375,15 @@ const firstExtrude = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_function_unary_in_pipe() {
let ast = r#"const w = 20
const l = 8
const h = 10
let ast = r#"w = 20
l = 8
h = 10
fn thing = (x) => {
fn thing(x) {
return -x
}
const firstExtrude = startSketchOn(XY)
firstExtrude = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1396,15 +1396,15 @@ const firstExtrude = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_function_array_in_pipe() {
let ast = r#"const w = 20
const l = 8
const h = 10
let ast = r#"w = 20
l = 8
h = 10
fn thing = (x) => {
fn thing(x) {
return [0, -x]
}
const firstExtrude = startSketchOn(XY)
firstExtrude = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1417,19 +1417,19 @@ const firstExtrude = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_function_call_in_pipe() {
let ast = r#"const w = 20
const l = 8
const h = 10
let ast = r#"w = 20
l = 8
h = 10
fn other_thing = (y) => {
fn other_thing(y) {
return -y
}
fn thing = (x) => {
fn thing(x) {
return other_thing(x)
}
const firstExtrude = startSketchOn(XY)
firstExtrude = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1442,8 +1442,8 @@ const firstExtrude = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_with_function_sketch() {
let ast = r#"fn box = (h, l, w) => {
const myBox = startSketchOn(XY)
let ast = r#"fn box(h, l, w) {
myBox = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1454,15 +1454,15 @@ const firstExtrude = startSketchOn(XY)
return myBox
}
const fnBox = box(3, 6, 10)"#;
fnBox = box(3, 6, 10)"#;
parse_execute(ast).await.unwrap();
}
#[tokio::test(flavor = "multi_thread")]
async fn test_get_member_of_object_with_function_period() {
let ast = r#"fn box = (obj) => {
let myBox = startSketchOn(XY)
let ast = r#"fn box(obj) {
myBox = startSketchOn(XY)
|> startProfile(at = obj.start)
|> line(end = [0, obj.l])
|> line(end = [obj.w, 0])
@ -1473,7 +1473,7 @@ const fnBox = box(3, 6, 10)"#;
return myBox
}
const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
thisBox = box({start = [0,0], l = 6, w = 10, h = 3})
"#;
parse_execute(ast).await.unwrap();
}
@ -1482,7 +1482,7 @@ const thisBox = box({start: [0,0], l: 6, w: 10, h: 3})
#[ignore] // https://github.com/KittyCAD/modeling-app/issues/3338
async fn test_object_member_starting_pipeline() {
let ast = r#"
fn test2 = () => {
fn test2() {
return {
thing: startSketchOn(XY)
|> startProfile(at = [0, 0])
@ -1493,7 +1493,7 @@ fn test2 = () => {
}
}
const x2 = test2()
x2 = test2()
x2.thing
|> extrude(length = 10)
@ -1504,7 +1504,7 @@ x2.thing
#[tokio::test(flavor = "multi_thread")]
#[ignore] // ignore til we get loops
async fn test_execute_with_function_sketch_loop_objects() {
let ast = r#"fn box = (obj) => {
let ast = r#"fn box(obj) {
let myBox = startSketchOn(XY)
|> startProfile(at = obj.start)
|> line(end = [0, obj.l])
@ -1517,7 +1517,7 @@ let myBox = startSketchOn(XY)
}
for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h: 1.5}] {
const thisBox = box(var)
thisBox = box(var)
}"#;
parse_execute(ast).await.unwrap();
@ -1526,8 +1526,8 @@ for var in [{start: [0,0], l: 6, w: 10, h: 3}, {start: [-10,-10], l: 3, w: 5, h:
#[tokio::test(flavor = "multi_thread")]
#[ignore] // ignore til we get loops
async fn test_execute_with_function_sketch_loop_array() {
let ast = r#"fn box = (h, l, w, start) => {
const myBox = startSketchOn(XY)
let ast = r#"fn box(h, l, w, start) {
myBox = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, l])
|> line(end = [w, 0])
@ -1548,8 +1548,8 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
#[tokio::test(flavor = "multi_thread")]
async fn test_get_member_of_array_with_function() {
let ast = r#"fn box = (arr) => {
let myBox =startSketchOn(XY)
let ast = r#"fn box(arr) {
myBox =startSketchOn(XY)
|> startProfile(at = arr[0])
|> line(end = [0, arr[1]])
|> line(end = [arr[2], 0])
@ -1560,7 +1560,7 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
return myBox
}
const thisBox = box([[0,0], 6, 10, 3])
thisBox = box([[0,0], 6, 10, 3])
"#;
parse_execute(ast).await.unwrap();
@ -1569,27 +1569,18 @@ const thisBox = box([[0,0], 6, 10, 3])
#[tokio::test(flavor = "multi_thread")]
async fn test_function_cannot_access_future_definitions() {
let ast = r#"
fn returnX = () => {
fn returnX() {
// x shouldn't be defined yet.
return x
}
const x = 5
x = 5
const answer = returnX()"#;
answer = returnX()"#;
let result = parse_execute(ast).await;
let err = result.unwrap_err();
assert_eq!(
err,
KclError::UndefinedValue(KclErrorDetails {
message: "`x` is not defined".to_owned(),
source_ranges: vec![
SourceRange::new(64, 65, ModuleId::default()),
SourceRange::new(97, 106, ModuleId::default())
],
}),
);
assert_eq!(err.message(), "`x` is not defined");
}
#[tokio::test(flavor = "multi_thread")]
@ -1619,7 +1610,7 @@ type Other = MyTy | Helix
#[tokio::test(flavor = "multi_thread")]
async fn test_cannot_shebang_in_fn() {
let ast = r#"
fn foo () {
fn foo() {
#!hello
return true
}
@ -1633,7 +1624,7 @@ foo
err,
KclError::Syntax(KclErrorDetails {
message: "Unexpected token: #".to_owned(),
source_ranges: vec![SourceRange::new(15, 16, ModuleId::default())],
source_ranges: vec![SourceRange::new(14, 15, ModuleId::default())],
}),
);
}
@ -1641,36 +1632,30 @@ foo
#[tokio::test(flavor = "multi_thread")]
async fn test_pattern_transform_function_cannot_access_future_definitions() {
let ast = r#"
fn transform = (replicaId) => {
fn transform(replicaId) {
// x shouldn't be defined yet.
let scale = x
scale = x
return {
translate: [0, 0, replicaId * 10],
scale: [scale, 1, 0],
translate = [0, 0, replicaId * 10],
scale = [scale, 1, 0],
}
}
fn layer = () => {
fn layer() {
return startSketchOn(XY)
|> circle( center= [0, 0], radius= 1 , tag =$tag1)
|> circle( center= [0, 0], radius= 1, tag = $tag1)
|> extrude(length = 10)
}
const x = 5
x = 5
// The 10 layers are replicas of each other, with a transform applied to each.
let shape = layer() |> patternTransform(instances = 10, transform = transform)
shape = layer() |> patternTransform(instances = 10, transform = transform)
"#;
let result = parse_execute(ast).await;
let err = result.unwrap_err();
assert_eq!(
err,
KclError::UndefinedValue(KclErrorDetails {
message: "`x` is not defined".to_owned(),
source_ranges: vec![SourceRange::new(80, 81, ModuleId::default())],
}),
);
assert_eq!(err.message(), "`x` is not defined",);
}
// ADAM: Move some of these into simulation tests.
@ -1689,7 +1674,7 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_math_execute() {
let ast = r#"const myVar = 1 + 2 * (3 - 4) / -5 + 6"#;
let ast = r#"myVar = 1 + 2 * (3 - 4) / -5 + 6"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
7.4,
@ -1701,7 +1686,7 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_math_execute_start_negative() {
let ast = r#"const myVar = -5 + 6"#;
let ast = r#"myVar = -5 + 6"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
1.0,
@ -1713,7 +1698,7 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_math_execute_with_pi() {
let ast = r#"const myVar = PI * 2"#;
let ast = r#"myVar = PI * 2"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
std::f64::consts::TAU,
@ -1725,7 +1710,7 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_math_define_decimal_without_leading_zero() {
let ast = r#"let thing = .4 + 7"#;
let ast = r#"thing = .4 + 7"#;
let result = parse_execute(ast).await.unwrap();
assert_eq!(
7.4,
@ -1737,12 +1722,12 @@ let shape = layer() |> patternTransform(instances = 10, transform = transform)
#[tokio::test(flavor = "multi_thread")]
async fn test_zero_param_fn() {
let ast = r#"const sigmaAllow = 35000 // psi
const leg1 = 5 // inches
const leg2 = 8 // inches
fn thickness = () => { return 0.56 }
let ast = r#"sigmaAllow = 35000 // psi
leg1 = 5 // inches
leg2 = 8 // inches
fn thickness() { return 0.56 }
const bracket = startSketchOn(XY)
bracket = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
@ -1765,7 +1750,7 @@ d = !returnTrue()
assertIs(!false, error = "expected to pass")
fn check = (x) => {
fn check(x) {
assertIs(!x, error = "expected argument to be false")
return true
}
@ -1802,74 +1787,56 @@ check(false)
async fn test_unary_operator_not_on_non_bool_fails() {
let code1 = r#"
// Yup, this is null.
let myNull = 0 / 0
let notNull = !myNull
myNull = 0 / 0
notNull = !myNull
"#;
assert_eq!(
parse_execute(code1).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: number".to_owned(),
source_ranges: vec![SourceRange::new(56, 63, ModuleId::default())],
})
parse_execute(code1).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: number",
);
let code2 = "let notZero = !0";
let code2 = "notZero = !0";
assert_eq!(
parse_execute(code2).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: number".to_owned(),
source_ranges: vec![SourceRange::new(14, 16, ModuleId::default())],
})
parse_execute(code2).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: number",
);
let code3 = r#"
let notEmptyString = !""
notEmptyString = !""
"#;
assert_eq!(
parse_execute(code3).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: string (text)".to_owned(),
source_ranges: vec![SourceRange::new(22, 25, ModuleId::default())],
})
parse_execute(code3).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: string (text)",
);
let code4 = r#"
let obj = { a: 1 }
let notMember = !obj.a
obj = { a = 1 }
notMember = !obj.a
"#;
assert_eq!(
parse_execute(code4).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: number".to_owned(),
source_ranges: vec![SourceRange::new(36, 42, ModuleId::default())],
})
parse_execute(code4).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: number",
);
let code5 = "
let a = []
let notArray = !a";
a = []
notArray = !a";
assert_eq!(
parse_execute(code5).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: array (list)".to_owned(),
source_ranges: vec![SourceRange::new(27, 29, ModuleId::default())],
})
parse_execute(code5).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: array (list)",
);
let code6 = "
let x = {}
let notObject = !x";
x = {}
notObject = !x";
assert_eq!(
parse_execute(code6).await.unwrap_err(),
KclError::Semantic(KclErrorDetails {
message: "Cannot apply unary operator ! to non-boolean value: object".to_owned(),
source_ranges: vec![SourceRange::new(28, 30, ModuleId::default())],
})
parse_execute(code6).await.unwrap_err().message(),
"Cannot apply unary operator ! to non-boolean value: object",
);
let code7 = "
fn x = () => { return 1 }
let notFunction = !x";
fn x() { return 1 }
notFunction = !x";
let fn_err = parse_execute(code7).await.unwrap_err();
// These are currently printed out as JSON objects, so we don't want to
// check the full error.
@ -1882,8 +1849,8 @@ let notFunction = !x";
);
let code8 = "
let myTagDeclarator = $myTag
let notTagDeclarator = !myTagDeclarator";
myTagDeclarator = $myTag
notTagDeclarator = !myTagDeclarator";
let tag_declarator_err = parse_execute(code8).await.unwrap_err();
// These are currently printed out as JSON objects, so we don't want to
// check the full error.
@ -1896,8 +1863,8 @@ let notTagDeclarator = !myTagDeclarator";
);
let code9 = "
let myTagDeclarator = $myTag
let notTagIdentifier = !myTag";
myTagDeclarator = $myTag
notTagIdentifier = !myTag";
let tag_identifier_err = parse_execute(code9).await.unwrap_err();
// These are currently printed out as JSON objects, so we don't want to
// check the full error.
@ -1909,27 +1876,27 @@ let notTagIdentifier = !myTag";
tag_identifier_err
);
let code10 = "let notPipe = !(1 |> 2)";
let code10 = "notPipe = !(1 |> 2)";
assert_eq!(
// TODO: We don't currently parse this, but we should. It should be
// a runtime error instead.
parse_execute(code10).await.unwrap_err(),
KclError::Syntax(KclErrorDetails {
message: "Unexpected token: !".to_owned(),
source_ranges: vec![SourceRange::new(14, 15, ModuleId::default())],
source_ranges: vec![SourceRange::new(10, 11, ModuleId::default())],
})
);
let code11 = "
fn identity = (x) => { return x }
let notPipeSub = 1 |> identity(!%))";
fn identity(x) { return x }
notPipeSub = 1 |> identity(!%))";
assert_eq!(
// TODO: We don't currently parse this, but we should. It should be
// a runtime error instead.
parse_execute(code11).await.unwrap_err(),
KclError::Syntax(KclErrorDetails {
message: "Unexpected token: |>".to_owned(),
source_ranges: vec![SourceRange::new(54, 56, ModuleId::default())],
source_ranges: vec![SourceRange::new(44, 46, ModuleId::default())],
})
);
@ -1940,20 +1907,20 @@ let notPipeSub = 1 |> identity(!%))";
#[tokio::test(flavor = "multi_thread")]
async fn test_math_negative_variable_in_binary_expression() {
let ast = r#"const sigmaAllow = 35000 // psi
const width = 1 // inch
let ast = r#"sigmaAllow = 35000 // psi
width = 1 // inch
const p = 150 // lbs
const distance = 6 // inches
const FOS = 2
p = 150 // lbs
distance = 6 // inches
FOS = 2
const leg1 = 5 // inches
const leg2 = 8 // inches
leg1 = 5 // inches
leg2 = 8 // inches
const thickness_squared = distance * p * FOS * 6 / sigmaAllow
const thickness = 0.56 // inches. App does not support square root function yet
thickness_squared = distance * p * FOS * 6 / sigmaAllow
thickness = 0.56 // inches. App does not support square root function yet
const bracket = startSketchOn(XY)
bracket = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
@ -1965,7 +1932,7 @@ const bracket = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_execute_function_no_return() {
let ast = r#"fn test = (origin) => {
let ast = r#"fn test(origin) {
origin
}
@ -1978,16 +1945,16 @@ test([0, 0])
#[tokio::test(flavor = "multi_thread")]
async fn test_math_doubly_nested_parens() {
let ast = r#"const sigmaAllow = 35000 // psi
const width = 4 // inch
const p = 150 // Force on shelf - lbs
const distance = 6 // inches
const FOS = 2
const leg1 = 5 // inches
const leg2 = 8 // inches
const thickness_squared = (distance * p * FOS * 6 / (sigmaAllow - width))
const thickness = 0.32 // inches. App does not support square root function yet
const bracket = startSketchOn(XY)
let ast = r#"sigmaAllow = 35000 // psi
width = 4 // inch
p = 150 // Force on shelf - lbs
distance = 6 // inches
FOS = 2
leg1 = 5 // inches
leg2 = 8 // inches
thickness_squared = (distance * p * FOS * 6 / (sigmaAllow - width))
thickness = 0.32 // inches. App does not support square root function yet
bracket = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
@ -2002,16 +1969,16 @@ const bracket = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_math_nested_parens_one_less() {
let ast = r#"const sigmaAllow = 35000 // psi
const width = 4 // inch
const p = 150 // Force on shelf - lbs
const distance = 6 // inches
const FOS = 2
const leg1 = 5 // inches
const leg2 = 8 // inches
const thickness_squared = distance * p * FOS * 6 / (sigmaAllow - width)
const thickness = 0.32 // inches. App does not support square root function yet
const bracket = startSketchOn(XY)
let ast = r#" sigmaAllow = 35000 // psi
width = 4 // inch
p = 150 // Force on shelf - lbs
distance = 6 // inches
FOS = 2
leg1 = 5 // inches
leg2 = 8 // inches
thickness_squared = distance * p * FOS * 6 / (sigmaAllow - width)
thickness = 0.32 // inches. App does not support square root function yet
bracket = startSketchOn(XY)
|> startProfile(at = [0,0])
|> line(end = [0, leg1])
|> line(end = [leg2, 0])
@ -2026,11 +1993,11 @@ const bracket = startSketchOn(XY)
#[tokio::test(flavor = "multi_thread")]
async fn test_fn_as_operand() {
let ast = r#"fn f = () => { return 1 }
let x = f()
let y = x + 1
let z = f() + 1
let w = f() + f()
let ast = r#"fn f() { return 1 }
x = f()
y = x + 1
z = f() + 1
w = f() + f()
"#;
parse_execute(ast).await.unwrap();
}

View File

@ -84,34 +84,10 @@ mod tests {
#[tokio::test]
async fn z0001_const() {
assert_finding!(
lint_variables,
Z0001,
"const Thickness = 0.5",
"found 'Thickness'",
None
);
assert_finding!(
lint_variables,
Z0001,
"const THICKNESS = 0.5",
"found 'THICKNESS'",
None
);
assert_finding!(
lint_variables,
Z0001,
"const THICC_NES = 0.5",
"found 'THICC_NES'",
None
);
assert_finding!(
lint_variables,
Z0001,
"const thicc_nes = 0.5",
"found 'thicc_nes'",
None
);
assert_finding!(lint_variables, Z0001, "Thickness = 0.5", "found 'Thickness'", None);
assert_finding!(lint_variables, Z0001, "THICKNESS = 0.5", "found 'THICKNESS'", None);
assert_finding!(lint_variables, Z0001, "THICC_NES = 0.5", "found 'THICC_NES'", None);
assert_finding!(lint_variables, Z0001, "thicc_nes = 0.5", "found 'thicc_nes'", None);
}
test_finding!(
@ -120,13 +96,13 @@ mod tests {
Z0001,
"\
// Define constants
const pipeLength = 40
const pipeSmallDia = 10
const pipeLargeDia = 20
const thickness = 0.5
pipeLength = 40
pipeSmallDia = 10
pipeLargeDia = 20
thickness = 0.5
// Create the sketch to be revolved around the y-axis. Use the small diameter, large diameter, length, and thickness to define the sketch.
const Part001 = startSketchOn(XY)
Part001 = startSketchOn(XY)
|> startProfile(at = [pipeLargeDia - (thickness / 2), 38])
|> line(end = [thickness, 0])
|> line(end = [0, -1])
@ -152,13 +128,13 @@ const Part001 = startSketchOn(XY)
Z0001,
"\
// Define constants
const pipeLength = 40
const pipeSmallDia = 10
const pipeLargeDia = 20
const thickness = 0.5
pipeLength = 40
pipeSmallDia = 10
pipeLargeDia = 20
thickness = 0.5
// Create the sketch to be revolved around the y-axis. Use the small diameter, large diameter, length, and thickness to define the sketch.
const part001 = startSketchOn(XY)
part001 = startSketchOn(XY)
|> startProfile(at = [pipeLargeDia - (thickness / 2), 38])
|> line(end = [thickness, 0])
|> line(end = [0, -1])
@ -181,7 +157,7 @@ const part001 = startSketchOn(XY)
lint_object_properties,
Z0001,
"\
let circ = {angle_start = 0, angle_end = 360, radius = 5}
circ = {angle_start = 0, angle_end = 360, radius = 5}
",
"found 'angle_start'",
None

View File

@ -262,15 +262,15 @@ impl Backend {
// if self.dev_mode
if false {
completion_list.push(
r#"fn cube = (pos, scale) => {
const sg = startSketchOn('XY')
r#"fn cube(pos, scale) {
sg = startSketchOn(XY)
|> startProfile(at = pos)
|> line([0, scale], %)
|> line([scale, 0], %)
|> line([0, -scale], %)
return sg
}
const part001 = cube([0,0], 20)
part001 = cube([0,0], 20)
|> close(%)
|> extrude(length=20)"#
.to_string(),

View File

@ -1573,10 +1573,10 @@ async fn test_kcl_lsp_semantic_tokens_with_modifiers() {
|> close()
|> extrude(length = 3.14)
thing = {blah: "foo"}
thing = {blah = "foo"}
bar = thing.blah
fn myFn = (param1) => {
fn myFn(param1) {
return param1
}"#
.to_string(),

View File

@ -3623,7 +3623,7 @@ mod tests {
#[test]
fn test_get_lsp_folding_ranges() {
let code = r#"const part001 = startSketchOn(XY)
let code = r#"part001 = startSketchOn(XY)
|> startProfile(at = [0.0000000000, 5.0000000000])
|> line([0.4900857016, -0.0240763666], %)
@ -3631,13 +3631,13 @@ startSketchOn(XY)
|> startProfile(at = [0.0000000000, 5.0000000000])
|> line([0.4900857016, -0.0240763666], %)
const part002 = "part002"
const things = [part001, 0.0]
let blah = 1
const foo = false
let baz = {a: 1, b: "thing"}
part002 = "part002"
things = [part001, 0.0]
blah = 1
foo = false
baz = {a = 1, b = "thing"}
fn ghi = (x) => {
fn ghi(x) {
return x
}
@ -3647,32 +3647,32 @@ ghi("things")
let folding_ranges = program.get_lsp_folding_ranges();
assert_eq!(folding_ranges.len(), 3);
assert_eq!(folding_ranges[0].start_line, 27);
assert_eq!(folding_ranges[0].end_line, 132);
assert_eq!(folding_ranges[0].end_line, 126);
assert_eq!(
folding_ranges[0].collapsed_text,
Some("part001 = startSketchOn(XY)".to_string())
);
assert_eq!(folding_ranges[1].start_line, 151);
assert_eq!(folding_ranges[1].end_line, 250);
assert_eq!(folding_ranges[1].start_line, 145);
assert_eq!(folding_ranges[1].end_line, 244);
assert_eq!(folding_ranges[1].collapsed_text, Some("startSketchOn(XY)".to_string()));
assert_eq!(folding_ranges[2].start_line, 380);
assert_eq!(folding_ranges[2].end_line, 399);
assert_eq!(folding_ranges[2].start_line, 350);
assert_eq!(folding_ranges[2].end_line, 363);
assert_eq!(folding_ranges[2].collapsed_text, Some("fn ghi(x) {".to_string()));
}
#[test]
fn test_get_lsp_symbols() {
let code = r#"const part001 = startSketchOn('XY')
let code = r#"part001 = startSketchOn(XY)
|> startProfile(at = [0.0000000000, 5.0000000000])
|> line([0.4900857016, -0.0240763666], %)
const part002 = "part002"
const things = [part001, 0.0]
let blah = 1
const foo = false
let baz = {a: 1, b: "thing"}
part002 = "part002"
things = [part001, 0.0]
blah = 1
foo = false
baz = {a = 1, b = "thing"}
fn ghi = (x) => {
fn ghi(x) {
return x
}
"#;
@ -3684,58 +3684,59 @@ fn ghi = (x) => {
#[test]
fn test_ast_in_comment() {
let some_program_string = r#"r = 20 / pow(pi(), exp = 1 / 3)
const h = 30
h = 30
// st
const cylinder = startSketchOn('-XZ')
cylinder = startSketchOn(-XZ)
|> startProfile(at = [50, 0])
|> arc({
angle_end: 360,
angle_start: 0,
radius: r
angle_end = 360,
angle_start = 0,
radius = r
}, %)
|> extrude(h, %)
"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
assert!(program.in_comment(50));
assert!(program.in_comment(43));
}
#[test]
fn test_ast_in_comment_pipe() {
let some_program_string = r#"r = 20 / pow(pi(), exp = 1 / 3)
const h = 30
h = 30
// st
const cylinder = startSketchOn('-XZ')
cylinder = startSketchOn(-XZ)
|> startProfile(at = [50, 0])
// comment
|> arc({
angle_end: 360,
angle_start: 0,
radius: r
angle_end= 360,
angle_start= 0,
radius= r
}, %)
|> extrude(h, %)
"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
assert!(program.in_comment(124));
assert!(program.in_comment(117));
}
#[test]
fn test_ast_in_comment_inline() {
let some_program_string = r#"const part001 = startSketchOn('XY')
let some_program_string = r#"part001 = startSketchOn(XY)
|> startProfile(at = [0,0])
|> xLine(length = 5) // lin
"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
assert!(program.in_comment(92));
assert!(program.in_comment(85));
}
#[tokio::test(flavor = "multi_thread")]
async fn test_parse_type_args_on_functions() {
let some_program_string = r#"fn thing = (arg0: number(mm), arg1: string, tag?: string) => {
let some_program_string = r#"fn thing(arg0: number(mm), arg1: string, tag?: string) {
return arg0
}"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -3766,7 +3767,7 @@ const cylinder = startSketchOn('-XZ')
#[tokio::test(flavor = "multi_thread")]
async fn test_parse_type_args_array_on_functions() {
let some_program_string = r#"fn thing = (arg0: [number], arg1: [string], tag?: string) => {
let some_program_string = r#"fn thing(arg0: [number], arg1: [string], tag?: string) {
return arg0
}"#;
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
@ -3803,7 +3804,7 @@ const cylinder = startSketchOn('-XZ')
#[tokio::test(flavor = "multi_thread")]
async fn test_parse_type_args_object_on_functions() {
let some_program_string = r#"fn thing = (arg0: [number], arg1: {thing: number, things: [string], more?: string}, tag?: string) => {
let some_program_string = r#"fn thing(arg0: [number], arg1: {thing: number, things: [string], more?: string}, tag?: string) {
return arg0
}"#;
let module_id = ModuleId::default();
@ -3836,14 +3837,14 @@ const cylinder = startSketchOn('-XZ')
name: "thing".to_owned(),
digest: None,
},
35,
40,
32,
37,
module_id,
),
type_: Some(Node::new(
Type::Primitive(PrimitiveType::Number(NumericSuffix::None)),
42,
48,
39,
45,
module_id
)),
default_value: None,
@ -3856,8 +3857,8 @@ const cylinder = startSketchOn('-XZ')
name: "things".to_owned(),
digest: None,
},
50,
56,
47,
53,
module_id,
),
type_: Some(Node::new(
@ -3865,8 +3866,8 @@ const cylinder = startSketchOn('-XZ')
ty: Box::new(Type::Primitive(PrimitiveType::String)),
len: ArrayLen::None
},
59,
65,
56,
62,
module_id
)),
default_value: None,
@ -3879,11 +3880,11 @@ const cylinder = startSketchOn('-XZ')
name: "more".to_owned(),
digest: None
},
68,
72,
65,
69,
module_id,
),
type_: Some(Node::new(Type::Primitive(PrimitiveType::String), 75, 81, module_id)),
type_: Some(Node::new(Type::Primitive(PrimitiveType::String), 72, 78, module_id)),
labeled: true,
default_value: Some(DefaultParamVal::none()),
digest: None
@ -3897,91 +3898,6 @@ const cylinder = startSketchOn('-XZ')
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_parse_return_type_on_functions() {
let some_program_string = r#"fn thing(): {thing: number, things: [string], more?: string} {
return 1
}"#;
let module_id = ModuleId::default();
let program = crate::parsing::parse_str(some_program_string, module_id).unwrap();
// Check the program output for the types of the parameters.
let function = program.body.first().unwrap();
let BodyItem::VariableDeclaration(var_decl) = function else {
panic!("expected a variable declaration")
};
let Expr::FunctionExpression(ref func_expr) = var_decl.declaration.init else {
panic!("expected a function expression")
};
let params = &func_expr.params;
assert_eq!(params.len(), 0);
assert_eq!(
func_expr.return_type.as_ref().unwrap().inner,
Type::Object {
properties: vec![
Parameter {
identifier: Node::new(
Identifier {
name: "thing".to_owned(),
digest: None
},
13,
18,
module_id,
),
type_: Some(Node::new(
Type::Primitive(PrimitiveType::Number(NumericSuffix::None)),
20,
26,
module_id
)),
default_value: None,
labeled: true,
digest: None
},
Parameter {
identifier: Node::new(
Identifier {
name: "things".to_owned(),
digest: None
},
28,
34,
module_id,
),
type_: Some(Node::new(
Type::Array {
ty: Box::new(Type::Primitive(PrimitiveType::String)),
len: ArrayLen::None
},
37,
43,
module_id
)),
default_value: None,
labeled: true,
digest: None
},
Parameter {
identifier: Node::new(
Identifier {
name: "more".to_owned(),
digest: None
},
46,
50,
module_id,
),
type_: Some(Node::new(Type::Primitive(PrimitiveType::String), 53, 59, module_id)),
labeled: true,
default_value: Some(DefaultParamVal::none()),
digest: None
}
]
}
);
}
#[test]
fn required_params() {
for (i, (test_name, expected, function_expr)) in [

View File

@ -936,7 +936,7 @@ fn object_property(i: &mut TokenSlice) -> PResult<Node<ObjectProperty>> {
);
if sep.token_type == TokenType::Colon {
ParseContext::warn(
ParseContext::err(
CompilationError::err(
sep.into(),
"Using `:` to initialize objects is deprecated, prefer using `=`.",
@ -1221,20 +1221,10 @@ fn if_expr(i: &mut TokenSlice) -> PResult<BoxNode<IfExpression>> {
fn function_expr(i: &mut TokenSlice) -> PResult<Expr> {
let fn_tok = opt(fun).parse_next(i)?;
ignore_whitespace(i);
let (result, has_arrow) = function_decl.parse_next(i)?;
let result = function_decl.parse_next(i)?;
if fn_tok.is_none() {
if has_arrow {
ParseContext::warn(
CompilationError::err(
result.as_source_range().start_as_range(),
"Missing `fn` in function declaration",
)
.with_suggestion("Add `fn`", "fn", None, Tag::None),
);
} else {
let err = CompilationError::fatal(result.as_source_range(), "Anonymous function requires `fn` before `(`");
return Err(ErrMode::Cut(err.into()));
}
let err = CompilationError::fatal(result.as_source_range(), "Anonymous function requires `fn` before `(`");
return Err(ErrMode::Cut(err.into()));
}
Ok(Expr::FunctionExpression(Box::new(result)))
}
@ -1244,7 +1234,7 @@ fn function_expr(i: &mut TokenSlice) -> PResult<Expr> {
// const x = arg0 + arg1;
// return x
// }
fn function_decl(i: &mut TokenSlice) -> PResult<(Node<FunctionExpression>, bool)> {
fn function_decl(i: &mut TokenSlice) -> PResult<Node<FunctionExpression>> {
fn return_type(i: &mut TokenSlice) -> PResult<Node<Type>> {
colon(i)?;
ignore_whitespace(i);
@ -1256,8 +1246,6 @@ fn function_decl(i: &mut TokenSlice) -> PResult<(Node<FunctionExpression>, bool)
let params = parameters(i)?;
close_paren(i)?;
ignore_whitespace(i);
let arrow = opt(big_arrow).parse_next(i)?;
ignore_whitespace(i);
// Optional return type.
let return_type = opt(return_type).parse_next(i)?;
ignore_whitespace(i);
@ -1282,18 +1270,7 @@ fn function_decl(i: &mut TokenSlice) -> PResult<(Node<FunctionExpression>, bool)
open.module_id,
);
let has_arrow =
if let Some(arrow) = arrow {
ParseContext::warn(
CompilationError::err(arrow.as_source_range(), "Unnecessary `=>` in function declaration")
.with_suggestion("Remove `=>`", "", None, Tag::Unnecessary),
);
true
} else {
false
};
Ok((result, has_arrow))
Ok(result)
}
/// E.g. `person.name`
@ -2140,7 +2117,7 @@ fn declaration(i: &mut TokenSlice) -> PResult<BoxNode<VariableDeclaration>> {
ignore_whitespace(i);
let val = function_decl
.map(|t| Box::new(t.0))
.map(Box::new)
.map(Expr::FunctionExpression)
.context(expected("a KCL function expression, like () { return 1 }"))
.parse_next(i);
@ -2174,7 +2151,7 @@ fn declaration(i: &mut TokenSlice) -> PResult<BoxNode<VariableDeclaration>> {
if let Some((_, tok)) = decl_token {
let range_to_remove = SourceRange::new(tok.start, id.start, id.module_id);
ParseContext::warn(
ParseContext::err(
CompilationError::err(
tok.as_source_range(),
format!(
@ -2582,12 +2559,6 @@ fn some_brace(symbol: &'static str, i: &mut TokenSlice) -> PResult<Token> {
.parse_next(i)
}
/// Parse a => operator.
fn big_arrow(i: &mut TokenSlice) -> PResult<Token> {
one_of((TokenType::Operator, "=>"))
.context(expected("the => symbol, used for declaring functions"))
.parse_next(i)
}
/// Parse a |> operator.
fn pipe_operator(i: &mut TokenSlice) -> PResult<Token> {
one_of((TokenType::Operator, PIPE_OPERATOR))
@ -3313,7 +3284,7 @@ mod tests {
return 1
}"#;
let tokens = crate::parsing::token::lex(test_program, ModuleId::default()).unwrap();
let expr = function_decl.map(|t| t.0).parse_next(&mut tokens.as_slice()).unwrap();
let expr = function_decl.parse_next(&mut tokens.as_slice()).unwrap();
assert_eq!(expr.params, vec![]);
let comment_start = expr.body.body[0].get_comments();
let comment0 = expr.body.body[1].get_comments();
@ -3330,7 +3301,7 @@ mod tests {
comment */
}"#;
let tokens = crate::parsing::token::lex(test_program, ModuleId::default()).unwrap();
let expr = function_decl.map(|t| t.0).parse_next(&mut tokens.as_slice()).unwrap();
let expr = function_decl.parse_next(&mut tokens.as_slice()).unwrap();
let comment0 = &expr.body.non_code_meta.non_code_nodes.get(&0).unwrap()[0];
assert_eq!(comment0.value(), "block\ncomment");
}
@ -3399,7 +3370,7 @@ mySk1 = startSketchOn(XY)
}";
let module_id = ModuleId::from_usize(1);
let tokens = crate::parsing::token::lex(test_program, module_id).unwrap();
let expr = function_decl.map(|t| t.0).parse_next(&mut tokens.as_slice()).unwrap();
let expr = function_decl.parse_next(&mut tokens.as_slice()).unwrap();
assert_eq!(
expr.body.non_code_meta.start_nodes,
vec![Node::new(
@ -4559,7 +4530,7 @@ export fn cos(num: number(rad)): number(_) {}"#;
#[test]
fn zero_param_function() {
let code = r#"
fn firstPrimeNumber = () => {
fn firstPrimeNumber() {
return 2
}
firstPrimeNumber()
@ -4647,26 +4618,6 @@ thing(false)
crate::parsing::top_level_parse(some_program_string).unwrap();
}
#[test]
fn test_error_define_function_as_var() {
for name in ["var", "let", "const"] {
let some_program_string = format!(
r#"{} thing = (param) => {{
return true
}}
thing(false)
"#,
name
);
assert_err(
&some_program_string,
"Expected a `fn` variable kind, found: `const`",
[0, name.len()],
);
}
}
#[test]
fn test_error_define_var_as_function() {
// TODO: https://github.com/KittyCAD/modeling-app/issues/784
@ -4690,7 +4641,7 @@ thing(false)
#[test]
fn test_member_expression_sketch() {
let some_program_string = r#"fn cube = (pos, scale) => {
let some_program_string = r#"fn cube(pos, scale) {
sg = startSketchOn('XY')
|> startProfileAt(pos, %)
|> line([0, scale], %)
@ -4718,7 +4669,7 @@ let other_thing = 2 * cos(3)"#;
#[test]
fn test_negative_arguments() {
let some_program_string = r#"fn box = (p, h, l, w) => {
let some_program_string = r#"fn box(p, h, l, w) {
myBox = startSketchOn('XY')
|> startProfileAt(p, %)
|> line([0, l], %)
@ -4969,67 +4920,6 @@ bar = 1
);
}
#[test]
fn warn_object_expr() {
let some_program_string = "{ foo: bar }";
let (_, errs) = assert_no_err(some_program_string);
assert_eq!(errs.len(), 1);
assert_eq!(errs[0].apply_suggestion(some_program_string).unwrap(), "{ foo = bar }")
}
#[test]
fn warn_fn_decl() {
let some_program_string = r#"fn foo = () => {
return 0
}"#;
let (_, errs) = assert_no_err(some_program_string);
assert_eq!(errs.len(), 2);
let replaced = errs[0].apply_suggestion(some_program_string).unwrap();
let replaced = errs[1].apply_suggestion(&replaced).unwrap();
// Note the whitespace here is bad, but we're just testing the suggestion spans really. In
// real life we might reformat after applying suggestions.
assert_eq!(
replaced,
r#"fn foo () {
return 0
}"#
);
let some_program_string = r#"myMap = map([0..5], (n) => {
return n * 2
})"#;
let (_, errs) = assert_no_err(some_program_string);
assert_eq!(errs.len(), 2);
let replaced = errs[0].apply_suggestion(some_program_string).unwrap();
let replaced = errs[1].apply_suggestion(&replaced).unwrap();
assert_eq!(
replaced,
r#"myMap = map([0..5], fn(n) {
return n * 2
})"#
);
}
#[test]
fn warn_const() {
let some_program_string = r#"const foo = 0
let bar = 1
var baz = 2
"#;
let (_, errs) = assert_no_err(some_program_string);
assert_eq!(errs.len(), 3);
let replaced = errs[2].apply_suggestion(some_program_string).unwrap();
let replaced = errs[1].apply_suggestion(&replaced).unwrap();
let replaced = errs[0].apply_suggestion(&replaced).unwrap();
assert_eq!(
replaced,
r#"foo = 0
bar = 1
baz = 2
"#
);
}
#[test]
fn test_unary_not_on_keyword_bool() {
let some_program_string = r#"!true"#;
@ -5196,11 +5086,11 @@ mod snapshot_tests {
snapshot_test!(c, "myVar = min(-legLen(5, 4), 5)");
snapshot_test!(d, "myVar = 5 + 6 |> myFunc(45, %)");
snapshot_test!(e, "let x = 1 * (3 - 4)");
snapshot_test!(e, "x = 1 * (3 - 4)");
snapshot_test!(f, r#"x = 1 // this is an inline comment"#);
snapshot_test!(
g,
r#"fn x = () => {
r#"fn x() {
return sg
return sg
}"#
@ -5208,32 +5098,32 @@ mod snapshot_tests {
snapshot_test!(d2, r#"x = -leg2 + thickness"#);
snapshot_test!(
h,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = 1 - obj.a"#
);
snapshot_test!(
i,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = 1 - obj["a"]"#
);
snapshot_test!(
j,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = obj["a"] - 1"#
);
snapshot_test!(
k,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = [1 - obj["a"], 0]"#
);
snapshot_test!(
l,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = [obj["a"] - 1, 0]"#
);
snapshot_test!(
m,
r#"obj = { a: 1, b: 2 }
r#"obj = {a = 1, b = 2 }
height = [obj["a"] -1, 0]"#
);
snapshot_test!(n, "height = 1 - obj.a");
@ -5242,7 +5132,7 @@ mod snapshot_tests {
snapshot_test!(q, r#"height = [ obj["a"], 0 ]"#);
snapshot_test!(
r,
r#"obj = { a: 1, b: 2 }
r#"obj = { a = 1, b = 2 }
height = obj["a"]"#
);
snapshot_test!(s, r#"prop = yo["one"][two]"#);
@ -5263,14 +5153,14 @@ mod snapshot_tests {
snapshot_test!(
ad,
r#"
fn firstPrimeNumber = () => {
fn firstPrimeNumber() {
return 2
}
firstPrimeNumber()"#
);
snapshot_test!(
ae,
r#"fn thing = (param) => {
r#"fn thing(param) {
return true
}
thing(false)"#
@ -5300,10 +5190,10 @@ mod snapshot_tests {
snapshot_test!(ar, r#"5 + "a""#);
snapshot_test!(at, "line([0, l], %)");
snapshot_test!(au, include_str!("../../e2e/executor/inputs/cylinder.kcl"));
snapshot_test!(av, "fn f = (angle?) => { return default(angle, 360) }");
snapshot_test!(av, "fn f(angle?) { return default(angle, 360) }");
snapshot_test!(
aw,
"let numbers = [
"numbers = [
1,
// A,
// B,
@ -5312,7 +5202,7 @@ mod snapshot_tests {
);
snapshot_test!(
ax,
"let numbers = [
"numbers = [
1,
2,
// A,
@ -5329,7 +5219,7 @@ mod snapshot_tests {
);
snapshot_test!(
az,
"let props = {
"props = {
a: 1,
// b: 2,
c: 3
@ -5359,14 +5249,14 @@ my14 = 4 ^ 2 - 3 ^ 2 * 2
5
}"#
);
snapshot_test!(be, "let x = 3 == 3");
snapshot_test!(bf, "let x = 3 != 3");
snapshot_test!(be, "x = 3 == 3");
snapshot_test!(bf, "x = 3 != 3");
snapshot_test!(bg, r#"x = 4"#);
snapshot_test!(bh, "obj = {center : [10, 10], radius: 5}");
snapshot_test!(bh, "obj = {center = [10, 10], radius =5}");
snapshot_test!(
bi,
r#"x = 3
obj = { x, y: 4}"#
obj = { x, y = 4}"#
);
snapshot_test!(bj, "true");
snapshot_test!(bk, "truee");

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 5,
"declaration": {
"commentStart": 8,
"end": 57,
"end": 51,
"id": {
"commentStart": 8,
"end": 24,
@ -21,10 +21,10 @@ expression: actual
"body": [
{
"argument": {
"commentStart": 50,
"end": 51,
"commentStart": 44,
"end": 45,
"raw": "2",
"start": 50,
"start": 44,
"type": "Literal",
"type": "Literal",
"value": {
@ -32,65 +32,65 @@ expression: actual
"suffix": "None"
}
},
"commentStart": 43,
"end": 51,
"start": 43,
"commentStart": 37,
"end": 45,
"start": 37,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 33,
"end": 57,
"start": 33
"commentStart": 27,
"end": 51,
"start": 27
},
"commentStart": 27,
"end": 57,
"commentStart": 24,
"end": 51,
"params": [],
"start": 27,
"start": 24,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 8,
"type": "VariableDeclarator"
},
"end": 57,
"end": 51,
"kind": "fn",
"start": 5,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 62,
"end": 80,
"commentStart": 56,
"end": 74,
"expression": {
"arguments": [],
"callee": {
"abs_path": false,
"commentStart": 62,
"end": 78,
"commentStart": 56,
"end": 72,
"name": {
"commentStart": 62,
"end": 78,
"commentStart": 56,
"end": 72,
"name": "firstPrimeNumber",
"start": 62,
"start": 56,
"type": "Identifier"
},
"path": [],
"start": 62,
"start": 56,
"type": "Name"
},
"commentStart": 62,
"end": 80,
"start": 62,
"commentStart": 56,
"end": 74,
"start": 56,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 62,
"start": 56,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 80,
"end": 74,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 3,
"end": 49,
"end": 43,
"id": {
"commentStart": 3,
"end": 8,
@ -21,62 +21,62 @@ expression: actual
"body": [
{
"argument": {
"commentStart": 39,
"end": 43,
"commentStart": 33,
"end": 37,
"raw": "true",
"start": 39,
"start": 33,
"type": "Literal",
"type": "Literal",
"value": true
},
"commentStart": 32,
"end": 43,
"start": 32,
"commentStart": 26,
"end": 37,
"start": 26,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 22,
"end": 49,
"start": 22
"commentStart": 16,
"end": 43,
"start": 16
},
"commentStart": 11,
"end": 49,
"commentStart": 8,
"end": 43,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 12,
"end": 17,
"commentStart": 9,
"end": 14,
"name": "param",
"start": 12,
"start": 9,
"type": "Identifier"
}
}
],
"start": 11,
"start": 8,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 3,
"type": "VariableDeclarator"
},
"end": 49,
"end": 43,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 54,
"end": 66,
"commentStart": 48,
"end": 60,
"expression": {
"arguments": [
{
"commentStart": 60,
"end": 65,
"commentStart": 54,
"end": 59,
"raw": "false",
"start": 60,
"start": 54,
"type": "Literal",
"type": "Literal",
"value": false
@ -84,31 +84,31 @@ expression: actual
],
"callee": {
"abs_path": false,
"commentStart": 54,
"end": 59,
"commentStart": 48,
"end": 53,
"name": {
"commentStart": 54,
"end": 59,
"commentStart": 48,
"end": 53,
"name": "thing",
"start": 54,
"start": 48,
"type": "Identifier"
},
"path": [],
"start": 54,
"start": 48,
"type": "Name"
},
"commentStart": 54,
"end": 66,
"start": 54,
"commentStart": 48,
"end": 60,
"start": 48,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 54,
"start": 48,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 66,
"end": 60,
"start": 0
}

View File

@ -7,13 +7,13 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 6,
"end": 104,
"commentStart": 0,
"end": 98,
"id": {
"commentStart": 6,
"end": 14,
"commentStart": 0,
"end": 8,
"name": "cylinder",
"start": 6,
"start": 0,
"type": "Identifier"
},
"init": {
@ -22,39 +22,39 @@ expression: actual
"arguments": [
{
"abs_path": false,
"commentStart": 31,
"end": 33,
"commentStart": 25,
"end": 27,
"name": {
"commentStart": 31,
"end": 33,
"commentStart": 25,
"end": 27,
"name": "XY",
"start": 31,
"start": 25,
"type": "Identifier"
},
"path": [],
"start": 31,
"start": 25,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 17,
"end": 30,
"commentStart": 11,
"end": 24,
"name": {
"commentStart": 17,
"end": 30,
"commentStart": 11,
"end": 24,
"name": "startSketchOn",
"start": 17,
"start": 11,
"type": "Identifier"
},
"path": [],
"start": 17,
"start": 11,
"type": "Name"
},
"commentStart": 17,
"end": 34,
"start": 17,
"commentStart": 11,
"end": 28,
"start": 11,
"type": "CallExpression",
"type": "CallExpression"
},
@ -63,20 +63,20 @@ expression: actual
{
"type": "LabeledArg",
"label": {
"commentStart": 49,
"end": 55,
"commentStart": 43,
"end": 49,
"name": "center",
"start": 49,
"start": 43,
"type": "Identifier"
},
"arg": {
"commentStart": 57,
"commentStart": 51,
"elements": [
{
"commentStart": 58,
"end": 59,
"commentStart": 52,
"end": 53,
"raw": "0",
"start": 58,
"start": 52,
"type": "Literal",
"type": "Literal",
"value": {
@ -85,10 +85,10 @@ expression: actual
}
},
{
"commentStart": 61,
"end": 62,
"commentStart": 55,
"end": 56,
"raw": "0",
"start": 61,
"start": 55,
"type": "Literal",
"type": "Literal",
"value": {
@ -97,8 +97,8 @@ expression: actual
}
}
],
"end": 63,
"start": 57,
"end": 57,
"start": 51,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
@ -106,17 +106,17 @@ expression: actual
{
"type": "LabeledArg",
"label": {
"commentStart": 65,
"end": 71,
"commentStart": 59,
"end": 65,
"name": "radius",
"start": 65,
"start": 59,
"type": "Identifier"
},
"arg": {
"commentStart": 73,
"end": 75,
"commentStart": 67,
"end": 69,
"raw": "22",
"start": 73,
"start": 67,
"type": "Literal",
"type": "Literal",
"value": {
@ -128,22 +128,22 @@ expression: actual
],
"callee": {
"abs_path": false,
"commentStart": 42,
"end": 48,
"commentStart": 36,
"end": 42,
"name": {
"commentStart": 42,
"end": 48,
"commentStart": 36,
"end": 42,
"name": "circle",
"start": 42,
"start": 36,
"type": "Identifier"
},
"path": [],
"start": 42,
"start": 36,
"type": "Name"
},
"commentStart": 42,
"end": 76,
"start": 42,
"commentStart": 36,
"end": 70,
"start": 36,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
@ -153,17 +153,17 @@ expression: actual
{
"type": "LabeledArg",
"label": {
"commentStart": 92,
"end": 98,
"commentStart": 86,
"end": 92,
"name": "length",
"start": 92,
"start": 86,
"type": "Identifier"
},
"arg": {
"commentStart": 101,
"end": 103,
"commentStart": 95,
"end": 97,
"raw": "14",
"start": 101,
"start": 95,
"type": "Literal",
"type": "Literal",
"value": {
@ -175,37 +175,37 @@ expression: actual
],
"callee": {
"abs_path": false,
"commentStart": 84,
"end": 91,
"commentStart": 78,
"end": 85,
"name": {
"commentStart": 84,
"end": 91,
"commentStart": 78,
"end": 85,
"name": "extrude",
"start": 84,
"start": 78,
"type": "Identifier"
},
"path": [],
"start": 84,
"start": 78,
"type": "Name"
},
"commentStart": 84,
"end": 104,
"start": 84,
"commentStart": 78,
"end": 98,
"start": 78,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 17,
"end": 104,
"start": 17,
"commentStart": 11,
"end": 98,
"start": 11,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 6,
"start": 0,
"type": "VariableDeclarator"
},
"end": 104,
"end": 98,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -213,6 +213,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 105,
"end": 99,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 3,
"end": 49,
"end": 43,
"id": {
"commentStart": 3,
"end": 4,
@ -24,25 +24,25 @@ expression: actual
"arguments": [
{
"abs_path": false,
"commentStart": 36,
"end": 41,
"commentStart": 30,
"end": 35,
"name": {
"commentStart": 36,
"end": 41,
"commentStart": 30,
"end": 35,
"name": "angle",
"start": 36,
"start": 30,
"type": "Identifier"
},
"path": [],
"start": 36,
"start": 30,
"type": "Name",
"type": "Name"
},
{
"commentStart": 43,
"end": 46,
"commentStart": 37,
"end": 40,
"raw": "360",
"start": 43,
"start": 37,
"type": "Literal",
"type": "Literal",
"value": {
@ -53,46 +53,46 @@ expression: actual
],
"callee": {
"abs_path": false,
"commentStart": 28,
"end": 35,
"commentStart": 22,
"end": 29,
"name": {
"commentStart": 28,
"end": 35,
"commentStart": 22,
"end": 29,
"name": "default",
"start": 28,
"start": 22,
"type": "Identifier"
},
"path": [],
"start": 28,
"start": 22,
"type": "Name"
},
"commentStart": 28,
"end": 47,
"start": 28,
"commentStart": 22,
"end": 41,
"start": 22,
"type": "CallExpression",
"type": "CallExpression"
},
"commentStart": 21,
"end": 47,
"start": 21,
"commentStart": 15,
"end": 41,
"start": 15,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 19,
"end": 49,
"start": 19
"commentStart": 13,
"end": 43,
"start": 13
},
"commentStart": 7,
"end": 49,
"commentStart": 4,
"end": 43,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 8,
"end": 13,
"commentStart": 5,
"end": 10,
"name": "angle",
"start": 8,
"start": 5,
"type": "Identifier"
},
"default_value": {
@ -102,14 +102,14 @@ expression: actual
}
}
],
"start": 7,
"start": 4,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 3,
"type": "VariableDeclarator"
},
"end": 49,
"end": 43,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
@ -117,6 +117,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 49,
"end": 43,
"start": 0
}

View File

@ -7,23 +7,23 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 91,
"commentStart": 0,
"end": 87,
"id": {
"commentStart": 4,
"end": 11,
"commentStart": 0,
"end": 7,
"name": "numbers",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 14,
"commentStart": 10,
"elements": [
{
"commentStart": 28,
"end": 29,
"commentStart": 24,
"end": 25,
"raw": "1",
"start": 28,
"start": 24,
"type": "Literal",
"type": "Literal",
"value": {
@ -32,10 +32,10 @@ expression: actual
}
},
{
"commentStart": 79,
"end": 80,
"commentStart": 75,
"end": 76,
"raw": "3",
"start": 79,
"start": 75,
"type": "Literal",
"type": "Literal",
"value": {
@ -44,14 +44,14 @@ expression: actual
}
}
],
"end": 91,
"end": 87,
"nonCodeMeta": {
"nonCodeNodes": {
"1": [
{
"commentStart": 43,
"end": 48,
"start": 43,
"commentStart": 39,
"end": 44,
"start": 39,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
@ -62,9 +62,9 @@ expression: actual
],
"2": [
{
"commentStart": 61,
"end": 66,
"start": 61,
"commentStart": 57,
"end": 62,
"start": 57,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
@ -76,14 +76,14 @@ expression: actual
},
"startNodes": []
},
"start": 14,
"start": 10,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 91,
"end": 87,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -91,6 +91,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 91,
"end": 87,
"start": 0
}

View File

@ -7,23 +7,23 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 91,
"commentStart": 0,
"end": 87,
"id": {
"commentStart": 4,
"end": 11,
"commentStart": 0,
"end": 7,
"name": "numbers",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 14,
"commentStart": 10,
"elements": [
{
"commentStart": 28,
"end": 29,
"commentStart": 24,
"end": 25,
"raw": "1",
"start": 28,
"start": 24,
"type": "Literal",
"type": "Literal",
"value": {
@ -32,10 +32,10 @@ expression: actual
}
},
{
"commentStart": 43,
"end": 44,
"commentStart": 39,
"end": 40,
"raw": "2",
"start": 43,
"start": 39,
"type": "Literal",
"type": "Literal",
"value": {
@ -44,14 +44,14 @@ expression: actual
}
}
],
"end": 91,
"end": 87,
"nonCodeMeta": {
"nonCodeNodes": {
"2": [
{
"commentStart": 58,
"end": 63,
"start": 58,
"commentStart": 54,
"end": 59,
"start": 54,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
@ -62,9 +62,9 @@ expression: actual
],
"3": [
{
"commentStart": 76,
"end": 81,
"start": 76,
"commentStart": 72,
"end": 77,
"start": 72,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
@ -76,14 +76,14 @@ expression: actual
},
"startNodes": []
},
"start": 14,
"start": 10,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 91,
"end": 87,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -91,6 +91,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 91,
"end": 87,
"start": 0
}

View File

@ -7,25 +7,25 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 79,
"commentStart": 0,
"end": 75,
"id": {
"commentStart": 4,
"end": 9,
"commentStart": 0,
"end": 5,
"name": "props",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 12,
"end": 79,
"commentStart": 8,
"end": 75,
"nonCodeMeta": {
"nonCodeNodes": {
"1": [
{
"commentStart": 44,
"end": 52,
"start": 44,
"commentStart": 40,
"end": 48,
"start": 40,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
@ -39,22 +39,22 @@ expression: actual
},
"properties": [
{
"commentStart": 26,
"end": 30,
"commentStart": 22,
"end": 26,
"key": {
"commentStart": 26,
"end": 27,
"commentStart": 22,
"end": 23,
"name": "a",
"start": 26,
"start": 22,
"type": "Identifier"
},
"start": 26,
"start": 22,
"type": "ObjectProperty",
"value": {
"commentStart": 29,
"end": 30,
"commentStart": 25,
"end": 26,
"raw": "1",
"start": 29,
"start": 25,
"type": "Literal",
"type": "Literal",
"value": {
@ -64,22 +64,22 @@ expression: actual
}
},
{
"commentStart": 65,
"end": 69,
"commentStart": 61,
"end": 65,
"key": {
"commentStart": 65,
"end": 66,
"commentStart": 61,
"end": 62,
"name": "c",
"start": 65,
"start": 61,
"type": "Identifier"
},
"start": 65,
"start": 61,
"type": "ObjectProperty",
"value": {
"commentStart": 68,
"end": 69,
"commentStart": 64,
"end": 65,
"raw": "3",
"start": 68,
"start": 64,
"type": "Literal",
"type": "Literal",
"value": {
@ -89,14 +89,14 @@ expression: actual
}
}
],
"start": 12,
"start": 8,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 79,
"end": 75,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -104,6 +104,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 79,
"end": 75,
"start": 0
}

View File

@ -7,23 +7,23 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 14,
"commentStart": 0,
"end": 10,
"id": {
"commentStart": 4,
"end": 5,
"commentStart": 0,
"end": 1,
"name": "x",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 8,
"end": 14,
"commentStart": 4,
"end": 10,
"left": {
"commentStart": 8,
"end": 9,
"commentStart": 4,
"end": 5,
"raw": "3",
"start": 8,
"start": 4,
"type": "Literal",
"type": "Literal",
"value": {
@ -33,10 +33,10 @@ expression: actual
},
"operator": "==",
"right": {
"commentStart": 13,
"end": 14,
"commentStart": 9,
"end": 10,
"raw": "3",
"start": 13,
"start": 9,
"type": "Literal",
"type": "Literal",
"value": {
@ -44,14 +44,14 @@ expression: actual
"suffix": "None"
}
},
"start": 8,
"start": 4,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 14,
"end": 10,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -59,6 +59,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 14,
"end": 10,
"start": 0
}

View File

@ -7,23 +7,23 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 14,
"commentStart": 0,
"end": 10,
"id": {
"commentStart": 4,
"end": 5,
"commentStart": 0,
"end": 1,
"name": "x",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 8,
"end": 14,
"commentStart": 4,
"end": 10,
"left": {
"commentStart": 8,
"end": 9,
"commentStart": 4,
"end": 5,
"raw": "3",
"start": 8,
"start": 4,
"type": "Literal",
"type": "Literal",
"value": {
@ -33,10 +33,10 @@ expression: actual
},
"operator": "!=",
"right": {
"commentStart": 13,
"end": 14,
"commentStart": 9,
"end": 10,
"raw": "3",
"start": 13,
"start": 9,
"type": "Literal",
"type": "Literal",
"value": {
@ -44,14 +44,14 @@ expression: actual
"suffix": "None"
}
},
"start": 8,
"start": 4,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 14,
"end": 10,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -59,6 +59,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 14,
"end": 10,
"start": 0
}

View File

@ -41,7 +41,7 @@ expression: actual
"commentStart": 14,
"declaration": {
"commentStart": 14,
"end": 30,
"end": 31,
"id": {
"commentStart": 14,
"end": 17,
@ -51,7 +51,7 @@ expression: actual
},
"init": {
"commentStart": 20,
"end": 30,
"end": 31,
"properties": [
{
"commentStart": 22,
@ -84,7 +84,7 @@ expression: actual
},
{
"commentStart": 25,
"end": 29,
"end": 30,
"key": {
"commentStart": 25,
"end": 26,
@ -95,10 +95,10 @@ expression: actual
"start": 25,
"type": "ObjectProperty",
"value": {
"commentStart": 28,
"end": 29,
"commentStart": 29,
"end": 30,
"raw": "4",
"start": 28,
"start": 29,
"type": "Literal",
"type": "Literal",
"value": {
@ -115,7 +115,7 @@ expression: actual
"start": 14,
"type": "VariableDeclarator"
},
"end": 30,
"end": 31,
"kind": "const",
"start": 14,
"type": "VariableDeclaration",
@ -123,6 +123,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 30,
"end": 31,
"start": 0
}

View File

@ -7,23 +7,23 @@ expression: actual
{
"commentStart": 0,
"declaration": {
"commentStart": 4,
"end": 18,
"commentStart": 0,
"end": 14,
"id": {
"commentStart": 4,
"end": 5,
"commentStart": 0,
"end": 1,
"name": "x",
"start": 4,
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 8,
"end": 18,
"commentStart": 4,
"end": 14,
"left": {
"commentStart": 8,
"end": 9,
"commentStart": 4,
"end": 5,
"raw": "1",
"start": 8,
"start": 4,
"type": "Literal",
"type": "Literal",
"value": {
@ -33,13 +33,13 @@ expression: actual
},
"operator": "*",
"right": {
"commentStart": 13,
"end": 18,
"commentStart": 9,
"end": 14,
"left": {
"commentStart": 13,
"end": 14,
"commentStart": 9,
"end": 10,
"raw": "3",
"start": 13,
"start": 9,
"type": "Literal",
"type": "Literal",
"value": {
@ -49,10 +49,10 @@ expression: actual
},
"operator": "-",
"right": {
"commentStart": 17,
"end": 18,
"commentStart": 13,
"end": 14,
"raw": "4",
"start": 17,
"start": 13,
"type": "Literal",
"type": "Literal",
"value": {
@ -60,18 +60,18 @@ expression: actual
"suffix": "None"
}
},
"start": 13,
"start": 9,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 8,
"start": 4,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 4,
"start": 0,
"type": "VariableDeclarator"
},
"end": 18,
"end": 14,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
@ -79,6 +79,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 18,
"end": 14,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 3,
"end": 58,
"end": 52,
"id": {
"commentStart": 3,
"end": 4,
@ -22,65 +22,65 @@ expression: actual
{
"argument": {
"abs_path": false,
"commentStart": 30,
"end": 32,
"commentStart": 24,
"end": 26,
"name": {
"commentStart": 30,
"end": 32,
"commentStart": 24,
"end": 26,
"name": "sg",
"start": 30,
"start": 24,
"type": "Identifier"
},
"path": [],
"start": 30,
"start": 24,
"type": "Name",
"type": "Name"
},
"commentStart": 23,
"end": 32,
"start": 23,
"commentStart": 17,
"end": 26,
"start": 17,
"type": "ReturnStatement",
"type": "ReturnStatement"
},
{
"argument": {
"abs_path": false,
"commentStart": 48,
"end": 50,
"commentStart": 42,
"end": 44,
"name": {
"commentStart": 48,
"end": 50,
"commentStart": 42,
"end": 44,
"name": "sg",
"start": 48,
"start": 42,
"type": "Identifier"
},
"path": [],
"start": 48,
"start": 42,
"type": "Name",
"type": "Name"
},
"commentStart": 41,
"end": 50,
"start": 41,
"commentStart": 35,
"end": 44,
"start": 35,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 13,
"end": 58,
"start": 13
"commentStart": 7,
"end": 52,
"start": 7
},
"commentStart": 7,
"end": 58,
"commentStart": 4,
"end": 52,
"params": [],
"start": 7,
"start": 4,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 3,
"type": "VariableDeclarator"
},
"end": 58,
"end": 52,
"kind": "fn",
"start": 0,
"type": "VariableDeclaration",
@ -88,6 +88,6 @@ expression: actual
}
],
"commentStart": 0,
"end": 58,
"end": 52,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,32 +78,32 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 27,
"declaration": {
"commentStart": 25,
"end": 43,
"commentStart": 27,
"end": 45,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 27,
"end": 33,
"name": "height",
"start": 25,
"start": 27,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"end": 43,
"commentStart": 36,
"end": 45,
"left": {
"commentStart": 34,
"end": 35,
"commentStart": 36,
"end": 37,
"raw": "1",
"start": 34,
"start": 36,
"type": "Literal",
"type": "Literal",
"value": {
@ -113,44 +113,44 @@ expression: actual
},
"operator": "-",
"right": {
"commentStart": 38,
"commentStart": 40,
"computed": false,
"end": 43,
"end": 45,
"object": {
"commentStart": 38,
"end": 41,
"commentStart": 40,
"end": 43,
"name": "obj",
"start": 38,
"start": 40,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 42,
"end": 43,
"commentStart": 44,
"end": 45,
"name": "a",
"start": 42,
"start": 44,
"type": "Identifier",
"type": "Identifier"
},
"start": 38,
"start": 40,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 34,
"start": 36,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 25,
"start": 27,
"type": "VariableDeclarator"
},
"end": 43,
"end": 45,
"kind": "const",
"start": 25,
"start": 27,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 43,
"end": 45,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,32 +78,32 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 26,
"commentStart": 28,
"declaration": {
"commentStart": 26,
"end": 47,
"commentStart": 28,
"end": 49,
"id": {
"commentStart": 26,
"end": 32,
"commentStart": 28,
"end": 34,
"name": "height",
"start": 26,
"start": 28,
"type": "Identifier"
},
"init": {
"commentStart": 35,
"end": 47,
"commentStart": 37,
"end": 49,
"left": {
"commentStart": 35,
"end": 36,
"commentStart": 37,
"end": 38,
"raw": "1",
"start": 35,
"start": 37,
"type": "Literal",
"type": "Literal",
"value": {
@ -113,45 +113,45 @@ expression: actual
},
"operator": "-",
"right": {
"commentStart": 39,
"commentStart": 41,
"computed": false,
"end": 47,
"end": 49,
"object": {
"commentStart": 39,
"end": 42,
"commentStart": 41,
"end": 44,
"name": "obj",
"start": 39,
"start": 41,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 43,
"end": 46,
"commentStart": 45,
"end": 48,
"raw": "\"a\"",
"start": 43,
"start": 45,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 39,
"start": 41,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 35,
"start": 37,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 26,
"start": 28,
"type": "VariableDeclarator"
},
"end": 47,
"end": 49,
"kind": "const",
"start": 26,
"start": 28,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 47,
"end": 49,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,58 +78,58 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 27,
"declaration": {
"commentStart": 25,
"end": 46,
"commentStart": 27,
"end": 48,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 27,
"end": 33,
"name": "height",
"start": 25,
"start": 27,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"end": 46,
"commentStart": 36,
"end": 48,
"left": {
"commentStart": 34,
"commentStart": 36,
"computed": false,
"end": 42,
"end": 44,
"object": {
"commentStart": 34,
"end": 37,
"commentStart": 36,
"end": 39,
"name": "obj",
"start": 34,
"start": 36,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 38,
"end": 41,
"commentStart": 40,
"end": 43,
"raw": "\"a\"",
"start": 38,
"start": 40,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 34,
"start": 36,
"type": "MemberExpression",
"type": "MemberExpression"
},
"operator": "-",
"right": {
"commentStart": 45,
"end": 46,
"commentStart": 47,
"end": 48,
"raw": "1",
"start": 45,
"start": 47,
"type": "Literal",
"type": "Literal",
"value": {
@ -137,21 +137,21 @@ expression: actual
"suffix": "None"
}
},
"start": 34,
"start": 36,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 25,
"start": 27,
"type": "VariableDeclarator"
},
"end": 46,
"end": 48,
"kind": "const",
"start": 25,
"start": 27,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 46,
"end": 48,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,35 +78,35 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 27,
"declaration": {
"commentStart": 25,
"end": 51,
"commentStart": 27,
"end": 53,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 27,
"end": 33,
"name": "height",
"start": 25,
"start": 27,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"commentStart": 36,
"elements": [
{
"commentStart": 35,
"end": 47,
"commentStart": 37,
"end": 49,
"left": {
"commentStart": 35,
"end": 36,
"commentStart": 37,
"end": 38,
"raw": "1",
"start": 35,
"start": 37,
"type": "Literal",
"type": "Literal",
"value": {
@ -116,39 +116,39 @@ expression: actual
},
"operator": "-",
"right": {
"commentStart": 39,
"commentStart": 41,
"computed": false,
"end": 47,
"end": 49,
"object": {
"commentStart": 39,
"end": 42,
"commentStart": 41,
"end": 44,
"name": "obj",
"start": 39,
"start": 41,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 43,
"end": 46,
"commentStart": 45,
"end": 48,
"raw": "\"a\"",
"start": 43,
"start": 45,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 39,
"start": 41,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 35,
"start": 37,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 49,
"end": 50,
"commentStart": 51,
"end": 52,
"raw": "0",
"start": 49,
"start": 51,
"type": "Literal",
"type": "Literal",
"value": {
@ -157,22 +157,22 @@ expression: actual
}
}
],
"end": 51,
"start": 34,
"end": 53,
"start": 36,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 25,
"start": 27,
"type": "VariableDeclarator"
},
"end": 51,
"end": 53,
"kind": "const",
"start": 25,
"start": 27,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 51,
"end": 53,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,61 +78,61 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 27,
"declaration": {
"commentStart": 25,
"end": 51,
"commentStart": 27,
"end": 53,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 27,
"end": 33,
"name": "height",
"start": 25,
"start": 27,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"commentStart": 36,
"elements": [
{
"commentStart": 35,
"end": 47,
"commentStart": 37,
"end": 49,
"left": {
"commentStart": 35,
"commentStart": 37,
"computed": false,
"end": 43,
"end": 45,
"object": {
"commentStart": 35,
"end": 38,
"commentStart": 37,
"end": 40,
"name": "obj",
"start": 35,
"start": 37,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 39,
"end": 42,
"commentStart": 41,
"end": 44,
"raw": "\"a\"",
"start": 39,
"start": 41,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 35,
"start": 37,
"type": "MemberExpression",
"type": "MemberExpression"
},
"operator": "-",
"right": {
"commentStart": 46,
"end": 47,
"commentStart": 48,
"end": 49,
"raw": "1",
"start": 46,
"start": 48,
"type": "Literal",
"type": "Literal",
"value": {
@ -140,15 +140,15 @@ expression: actual
"suffix": "None"
}
},
"start": 35,
"start": 37,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 49,
"end": 50,
"commentStart": 51,
"end": 52,
"raw": "0",
"start": 49,
"start": 51,
"type": "Literal",
"type": "Literal",
"value": {
@ -157,22 +157,22 @@ expression: actual
}
}
],
"end": 51,
"start": 34,
"end": 53,
"start": 36,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 25,
"start": 27,
"type": "VariableDeclarator"
},
"end": 51,
"end": 53,
"kind": "const",
"start": 25,
"start": 27,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 51,
"end": 53,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 21,
"id": {
"commentStart": 0,
"end": 3,
@ -18,19 +18,19 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 21,
"properties": [
{
"commentStart": 8,
"commentStart": 7,
"end": 12,
"key": {
"commentStart": 8,
"end": 9,
"commentStart": 7,
"end": 8,
"name": "a",
"start": 8,
"start": 7,
"type": "Identifier"
},
"start": 8,
"start": 7,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
@ -47,7 +47,7 @@ expression: actual
},
{
"commentStart": 14,
"end": 18,
"end": 19,
"key": {
"commentStart": 14,
"end": 15,
@ -58,10 +58,10 @@ expression: actual
"start": 14,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 18,
"end": 19,
"raw": "2",
"start": 17,
"start": 18,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,61 +78,61 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 21,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 26,
"declaration": {
"commentStart": 25,
"end": 50,
"commentStart": 26,
"end": 51,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 26,
"end": 32,
"name": "height",
"start": 25,
"start": 26,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"commentStart": 35,
"elements": [
{
"commentStart": 35,
"end": 46,
"commentStart": 36,
"end": 47,
"left": {
"commentStart": 35,
"commentStart": 36,
"computed": false,
"end": 43,
"end": 44,
"object": {
"commentStart": 35,
"end": 38,
"commentStart": 36,
"end": 39,
"name": "obj",
"start": 35,
"start": 36,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 39,
"end": 42,
"commentStart": 40,
"end": 43,
"raw": "\"a\"",
"start": 39,
"start": 40,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 35,
"start": 36,
"type": "MemberExpression",
"type": "MemberExpression"
},
"operator": "-",
"right": {
"commentStart": 45,
"end": 46,
"commentStart": 46,
"end": 47,
"raw": "1",
"start": 45,
"start": 46,
"type": "Literal",
"type": "Literal",
"value": {
@ -140,15 +140,15 @@ expression: actual
"suffix": "None"
}
},
"start": 35,
"start": 36,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 48,
"end": 49,
"commentStart": 49,
"end": 50,
"raw": "0",
"start": 48,
"start": 49,
"type": "Literal",
"type": "Literal",
"value": {
@ -157,22 +157,22 @@ expression: actual
}
}
],
"end": 50,
"start": 34,
"end": 51,
"start": 35,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 25,
"start": 26,
"type": "VariableDeclarator"
},
"end": 50,
"end": 51,
"kind": "const",
"start": 25,
"start": 26,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 50,
"end": 51,
"start": 0
}

View File

@ -8,7 +8,7 @@ expression: actual
"commentStart": 0,
"declaration": {
"commentStart": 0,
"end": 20,
"end": 22,
"id": {
"commentStart": 0,
"end": 3,
@ -18,11 +18,11 @@ expression: actual
},
"init": {
"commentStart": 6,
"end": 20,
"end": 22,
"properties": [
{
"commentStart": 8,
"end": 12,
"end": 13,
"key": {
"commentStart": 8,
"end": 9,
@ -33,10 +33,10 @@ expression: actual
"start": 8,
"type": "ObjectProperty",
"value": {
"commentStart": 11,
"end": 12,
"commentStart": 12,
"end": 13,
"raw": "1",
"start": 11,
"start": 12,
"type": "Literal",
"type": "Literal",
"value": {
@ -46,22 +46,22 @@ expression: actual
}
},
{
"commentStart": 14,
"end": 18,
"commentStart": 15,
"end": 20,
"key": {
"commentStart": 14,
"end": 15,
"commentStart": 15,
"end": 16,
"name": "b",
"start": 14,
"start": 15,
"type": "Identifier"
},
"start": 14,
"start": 15,
"type": "ObjectProperty",
"value": {
"commentStart": 17,
"end": 18,
"commentStart": 19,
"end": 20,
"raw": "2",
"start": 17,
"start": 19,
"type": "Literal",
"type": "Literal",
"value": {
@ -78,60 +78,60 @@ expression: actual
"start": 0,
"type": "VariableDeclarator"
},
"end": 20,
"end": 22,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 25,
"commentStart": 27,
"declaration": {
"commentStart": 25,
"end": 42,
"commentStart": 27,
"end": 44,
"id": {
"commentStart": 25,
"end": 31,
"commentStart": 27,
"end": 33,
"name": "height",
"start": 25,
"start": 27,
"type": "Identifier"
},
"init": {
"commentStart": 34,
"commentStart": 36,
"computed": false,
"end": 42,
"end": 44,
"object": {
"commentStart": 34,
"end": 37,
"commentStart": 36,
"end": 39,
"name": "obj",
"start": 34,
"start": 36,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 38,
"end": 41,
"commentStart": 40,
"end": 43,
"raw": "\"a\"",
"start": 38,
"start": 40,
"type": "Literal",
"type": "Literal",
"value": "a"
},
"start": 34,
"start": 36,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 25,
"start": 27,
"type": "VariableDeclarator"
},
"end": 42,
"end": 44,
"kind": "const",
"start": 25,
"start": 27,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 42,
"end": 44,
"start": 0
}

View File

@ -111,10 +111,10 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// // with a gap between the original (at x = 0) and the first replica
/// // (at x = 8). This is because `id` starts at 1.
/// fn transform(id) {
/// return { translate: [4 * (1+id), 0, 0] }
/// return { translate = [4 * (1+id), 0, 0] }
/// }
///
/// sketch001 = startSketchOn('XZ')
/// sketch001 = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = 2)
/// |> extrude(length = 5)
/// |> patternTransform(instances = 4, transform = transform)
@ -129,7 +129,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// p2 = [ l + x, l + y]
/// p3 = [ l + x, -l + y]
///
/// return startSketchOn('XY')
/// return startSketchOn(XY)
/// |> startProfile(at = p0)
/// |> line(endAbsolute = p1)
/// |> line(endAbsolute = p2)
@ -210,7 +210,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// }
/// // Each layer is just a pretty thin cylinder.
/// fn layer() {
/// return startSketchOn("XY") // or some other plane idk
/// return startSketchOn(XY) // or some other plane idk
/// |> circle(center = [0, 0], radius = 1, tag = $tag1)
/// |> extrude(length = h)
/// }
@ -222,11 +222,11 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
/// fn transform(i) {
/// // Transform functions can return multiple transforms. They'll be applied in order.
/// return [
/// { translate: [30 * i, 0, 0] },
/// { rotation: { angle: 45 * i } },
/// { translate = [30 * i, 0, 0] },
/// { rotation = { angle = 45 * i } },
/// ]
/// }
/// startSketchOn('XY')
/// startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> polygon(
/// radius = 10,
@ -283,12 +283,12 @@ async fn inner_pattern_transform<'a>(
/// ```no_run
/// // Each instance will be shifted along the X axis.
/// fn transform(id) {
/// return { translate: [4 * id, 0] }
/// return { translate = [4 * id, 0] }
/// }
///
/// // Sketch 4 circles.
/// sketch001 = startSketchOn('XZ')
/// |> circle(center= [0, 0], radius= 2)
/// sketch001 = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius= 2)
/// |> patternTransform2d(instances = 4, transform = transform)
/// ```
#[stdlib {
@ -715,7 +715,7 @@ pub async fn pattern_linear_2d(exec_state: &mut ExecState, args: Args) -> Result
/// of distance between each repetition, some specified number of times.
///
/// ```no_run
/// exampleSketch = startSketchOn('XZ')
/// exampleSketch = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = 1)
/// |> patternLinear2d(
/// axis = [1, 0],
@ -794,7 +794,7 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// of distance between each repetition, some specified number of times.
///
/// ```no_run
/// exampleSketch = startSketchOn('XZ')
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 2])
/// |> line(end = [3, 1])
@ -812,8 +812,8 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// ///
/// ```no_run
/// // Pattern a whole sketch on face.
/// let size = 100
/// const case = startSketchOn('XY')
/// size = 100
/// case = startSketchOn(XY)
/// |> startProfile(at = [-size, -size])
/// |> line(end = [2 * size, 0])
/// |> line(end = [0, 2 * size])
@ -821,11 +821,11 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// |> close(%)
/// |> extrude(length = 65)
///
/// const thing1 = startSketchOn(case, face = END)
/// thing1 = startSketchOn(case, face = END)
/// |> circle(center = [-size / 2, -size / 2], radius = 25)
/// |> extrude(length = 50)
///
/// const thing2 = startSketchOn(case, face = END)
/// thing2 = startSketchOn(case, face = END)
/// |> circle(center = [size / 2, -size / 2], radius = 25)
/// |> extrude(length = 50)
///
@ -840,8 +840,8 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
///
/// ```no_run
/// // Pattern an object on a face.
/// let size = 100
/// const case = startSketchOn('XY')
/// size = 100
/// case = startSketchOn(XY)
/// |> startProfile(at = [-size, -size])
/// |> line(end = [2 * size, 0])
/// |> line(end = [0, 2 * size])
@ -849,7 +849,7 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result
/// |> close(%)
/// |> extrude(length = 65)
///
/// const thing1 = startSketchOn(case, face = END)
/// thing1 = startSketchOn(case, face = END)
/// |> circle(center =[-size / 2, -size / 2], radius = 25)
/// |> extrude(length = 50)
///
@ -1043,7 +1043,7 @@ pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Resu
/// solid with respect to the center of the circle is maintained.
///
/// ```no_run
/// exampleSketch = startSketchOn('XZ')
/// exampleSketch = startSketchOn(XZ)
/// |> startProfile(at = [.5, 25])
/// |> line(end = [0, 5])
/// |> line(end = [-1, 0])
@ -1159,7 +1159,7 @@ pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Resu
/// solid with respect to the center of the circle is maintained.
///
/// ```no_run
/// exampleSketch = startSketchOn('XZ')
/// exampleSketch = startSketchOn(XZ)
/// |> circle(center = [0, 0], radius = 1)
///
/// example = extrude(exampleSketch, length = -5)

View File

@ -1406,7 +1406,7 @@ bar = [0 + 1 .. ten]
#[test]
fn test_recast_space_in_fn_call() {
let some_program_string = r#"fn thing = (x) => {
let some_program_string = r#"fn thing (x) {
return x + 1
}
@ -1611,7 +1611,7 @@ depth = 45.0
thk = 5
hole_diam = 5
// define a rectangular shape func
fn rectShape = (pos, w, l) => {
fn rectShape(pos, w, l) {
rr = startSketchOn('xy')
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
@ -1634,10 +1634,10 @@ scarlett_body = rectShape([0, 0], width, length)
]
)
// build the bracket sketch around the body
fn bracketSketch = (w, d, t) => {
fn bracketSketch(w, d, t) {
s = startSketchOn({
plane: {
origin: { x = 0, y = length / 2 + thk, z = 0 },
origin = { x = 0, y = length / 2 + thk, z = 0 },
x_axis = { x = 1, y = 0, z = 0 },
y_axis = { x = 0, y = 0, z = 1 },
z_axis = { x = 0, y = 1, z = 0 }
@ -1669,7 +1669,7 @@ bracket_body = bracketSketch(width, depth, thk)
// build the tabs of the mounting bracket (right side)
tabs_r = startSketchOn({
plane: {
origin: { x = 0, y = 0, z = depth + thk },
origin = { x = 0, y = 0, z = depth + thk },
x_axis = { x = 1, y = 0, z = 0 },
y_axis = { x = 0, y = 1, z = 0 },
z_axis = { x = 0, y = 0, z = 1 }
@ -1840,7 +1840,7 @@ tabs_l = startSketchOn({
#[test]
fn test_recast_nested_var_declaration_in_fn_body() {
let some_program_string = r#"fn cube = (pos, scale) => {
let some_program_string = r#"fn cube(pos, scale) {
sg = startSketchOn(XY)
|> startProfileAt(pos, %)
|> line([0, scale], %)
@ -1949,7 +1949,7 @@ cube(0, 0) as cub
#[test]
fn test_recast_comment_in_a_fn_block() {
let some_program_string = r#"fn myFn = () => {
let some_program_string = r#"fn myFn() {
// this is a comment
yo = { a = { b = { c = '123' } } } /* block
comment */
@ -2271,7 +2271,7 @@ blah = 1
foo = false
baz = {a: 1, part001: "thing"}
fn ghi = (part001) => {
fn ghi(part001) {
return part001
}
"#;
@ -2300,11 +2300,11 @@ fn ghi(part001) {
#[test]
fn test_recast_after_rename_fn_args() {
let some_program_string = r#"fn ghi = (x, y, z) => {
let some_program_string = r#"fn ghi(x, y, z) {
return x
}"#;
let mut program = crate::parsing::top_level_parse(some_program_string).unwrap();
program.rename_symbol("newName", 10);
program.rename_symbol("newName", 7);
let recasted = program.recast(&Default::default(), 0);
assert_eq!(
@ -2480,8 +2480,8 @@ type baz = Foo | Bar
#[test]
fn recast_nested_fn() {
let some_program_string = r#"fn f = () => {
return fn() => {
let some_program_string = r#"fn f() {
return fn() {
return 1
}
}"#;

View File

@ -313,11 +313,11 @@ mod tests {
fn check_ptr_eq() {
let program = kcl!(
"
const foo = 1
const bar = foo + 1
foo = 1
bar = foo + 1
fn myfn = () => {
const foo = 2
fn myfn() {
foo = 2
sin(foo)
}
"