Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
es2015::{ArrowFunctionsOptions, ES2015Options},
es2016::ES2016Options,
es2017::ES2017Options,
es2018::{ES2018Options, ObjectRestSpreadOptions},
es2018::ES2018Options,
es2019::ES2019Options,
es2020::ES2020Options,
es2021::ES2021Options,
Expand Down Expand Up @@ -71,15 +71,7 @@ impl EnvOptions {
},
es2016: ES2016Options { exponentiation_operator: true },
es2017: ES2017Options { async_to_generator: true },
es2018: ES2018Options {
// Turned off because it is not ready.
object_rest_spread: if include_unfinished_plugins {
Some(ObjectRestSpreadOptions::default())
} else {
None
},
async_generator_functions: true,
},
es2018: ES2018Options { object_rest_spread: None, async_generator_functions: true },
es2019: ES2019Options { optional_catch_binding: true },
es2020: ES2020Options {
nullish_coalescing_operator: true,
Expand Down
157 changes: 5 additions & 152 deletions tasks/transform_conformance/snapshots/babel_exec.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,156 +11,9 @@ Error: 'eval' and 'arguments' cannot be used as a binding identifier in strict m
❯ ssrTransformScript ../../node_modules/.pnpm/vite@5.4.8_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52319:11
❯ loadAndTransform ../../node_modules/.pnpm/vite@5.4.8_@types+node@22.9.0/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51917:72

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/12]⎯
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/4]⎯

⎯⎯⎯⎯⎯⎯ Failed Tests 11 ⎯⎯⎯⎯⎯⎯⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-objectRestNoSymbols-rest-ignore-symbols-exec.test.js > exec
AssertionError: expected true to be false // Object.is equality

- Expected
+ Received

- false
+ true

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-objectRestNoSymbols-rest-ignore-symbols-exec.test.js:12:19
10| expect(a).toBe(1);
11| expect(r.b).toBe(2);
12| expect(sym in r).toBe(false);
| ^
13| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-pureGetters-rest-remove-unused-excluded-keys-exec.test.js > exec
AssertionError: expected true to be false // Object.is equality

- Expected
+ Received

- false
+ true

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-pureGetters-rest-remove-unused-excluded-keys-exec.test.js:10:17
8| let { foo,...rest } = obj;
9| expect("foo" in rest).toBe(false);
10| expect(called).toBe(false);
| ^
11| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-pureGetters-spread-single-call-exec.test.js > exec
AssertionError: expected { foo: +0, middle: 1, bar: 1 } to deeply equal { foo: +0, middle: +0, bar: 1 }

- Expected
+ Received

Object {
"bar": 1,
"foo": 0,
- "middle": 0,
+ "middle": 1,
}

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-pureGetters-spread-single-call-exec.test.js:13:14
11| } };
12| let res = _objectSpread(_objectSpread(_objectSpread({}, withFoo), { m…
13| expect(res).toEqual({
| ^
14| foo: 0,
15| middle: 0,

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-setSpreadProperties-no-object-assign-exec-exec.test.js > exec
AssertionError: expected [Function] to throw an error
❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-setSpreadProperties-no-object-assign-exec-exec.test.js:14:5
12| expect(() => {
13| const objSpread = _objectSpread({}, obj);
14| }).toThrow();
| ^
15| const obj2 = { "NOWRITE": 456 };
16| expect(() => {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-setSpreadProperties-with-useBuiltIns-no-object-assign-exec-exec.test.js > exec
AssertionError: expected [Function] to throw an error
❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-assumption-setSpreadProperties-with-useBuiltIns-no-object-assign-exec-exec.test.js:14:5
12| expect(() => {
13| const objSpread = _objectSpread({}, obj);
14| }).toThrow();
| ^
15| const obj2 = { "NOWRITE": 456 };
16| expect(() => {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-expression-exec.test.js > exec
AssertionError: expected [ 1, 2 ] to deeply equal [ 1 ]

- Expected
+ Received

Array [
1,
+ 2,
]

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-expression-exec.test.js:11:14
9| log.push(2);
10| } });
11| expect(log).toEqual([1]);
| ^
12| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[7/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-loose-builtins-side-effect-exec.test.js > exec
AssertionError: expected { a: 1, b: 1 } to deeply equal { a: 2, b: 1 }

- Expected
+ Received

Object {
- "a": 2,
+ "a": 1,
"b": 1,
}

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-loose-builtins-side-effect-exec.test.js:9:12
7| };
8| var o = Object.assign(Object.assign({ a: 3 }, k), { b: k.a++ });
9| expect(o).toEqual({
| ^
10| a: 2,
11| b: 1

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[8/12]⎯

FAIL fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-loose-side-effect-exec.test.js > exec
AssertionError: expected { a: 1, b: 1 } to deeply equal { a: 2, b: 1 }

- Expected
+ Received

Object {
- "a": 2,
+ "a": 1,
"b": 1,
}

❯ fixtures/babel-plugin-transform-object-rest-spread-test-fixtures-object-spread-loose-side-effect-exec.test.js:9:12
7| };
8| var o = Object.assign(Object.assign({ a: 3 }, k), { b: k.a++ });
9| expect(o).toEqual({
| ^
10| a: 2,
11| b: 1

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[9/12]⎯
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯

FAIL fixtures/babel-preset-env-test-fixtures-plugins-integration-issue-15170-exec.test.js > exec
AssertionError: expected [Function] to not throw an error but 'ReferenceError: x is not defined' was thrown
Expand All @@ -178,7 +31,7 @@ undefined
| ^
7| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[10/12]⎯
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/4]⎯

FAIL fixtures/babel-preset-env-test-fixtures-sanity-check-es2015-constants-exec.test.js > exec
TypeError: Assignment to constant variable.
Expand All @@ -189,7 +42,7 @@ TypeError: Assignment to constant variable.
| ^
6| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[11/12]⎯
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/4]⎯

FAIL fixtures/babel-preset-env-test-fixtures-sanity-regex-dot-all-exec.test.js > exec
AssertionError: expected false to be true // Object.is equality
Expand All @@ -208,5 +61,5 @@ AssertionError: expected false to be true // Object.is equality
11| expect(/hello.world/su.test(input)).toBe(true);
12| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[12/12]⎯
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/4]⎯

2 changes: 1 addition & 1 deletion tasks/transform_conformance/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub const PLUGINS: &[&str] = &[
// "babel-plugin-transform-json-strings",
// // ES2018
"babel-plugin-transform-async-generator-functions",
"babel-plugin-transform-object-rest-spread",
// "babel-plugin-transform-object-rest-spread",
// // [Regex] "babel-plugin-transform-unicode-property-regex",
// "babel-plugin-transform-dotall-regex",
// // [Regex] "babel-plugin-transform-named-capturing-groups-regex",
Expand Down
23 changes: 20 additions & 3 deletions tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use oxc_tasks_common::{normalize_path, print_diff_in_terminal, project_root};
use crate::{
constants::{PLUGINS_NOT_SUPPORTED_YET, SKIP_TESTS, SNAPSHOT_TESTS},
driver::Driver,
fixture_root, oxc_test_root, packages_root,
fixture_root, oxc_test_root, packages_root, snap_root,
};

#[derive(Debug)]
Expand Down Expand Up @@ -194,7 +194,7 @@ impl TestCase {
match self.kind {
TestCaseKind::Conformance => self.test_conformance(filtered),
TestCaseKind::Exec => self.test_exec(filtered),
TestCaseKind::Snapshot => {}
TestCaseKind::Snapshot => self.test_snapshot(filtered),
}
}

Expand Down Expand Up @@ -342,7 +342,6 @@ impl TestCase {
.unwrap();
let new_file_name: String =
normalize_path(unprefixed_path).split('/').collect::<Vec<&str>>().join("-");

let mut target_path = fixture_root().join(new_file_name);
target_path.set_extension("test.js");
let content = Self::template(content);
Expand Down Expand Up @@ -373,6 +372,24 @@ test("exec", () => {{
}})"#
)
}

fn test_snapshot(&self, filtered: bool) {
let result = match self.transform(HelperLoaderMode::Runtime) {
Ok(code) => code,
Err(error) => error,
};
let path = snap_root().join(self.path.strip_prefix(packages_root()).unwrap());
if filtered {
println!("Input path: {:?}", &self.path);
println!("Output path: {path:?}");
println!("Input:\n{}\n", fs::read_to_string(&self.path).unwrap());
println!("Output:\n{result}\n");
}
if fs::write(&path, &result).is_err() {
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, &result).unwrap();
}
}
}

fn get_babel_error(error: &str) -> String {
Expand Down