Skip to content

Commit

Permalink
test(es): Use typescript test suite as a golden testing (#2456)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Oct 18, 2021
1 parent 7225f90 commit 675c0e7
Show file tree
Hide file tree
Showing 6,663 changed files with 251,177 additions and 16 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.72.1"
version = "0.72.2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand Down
4 changes: 2 additions & 2 deletions bundler/src/bundler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use self::scope::Scope;
use crate::{Hook, Load, ModuleId, Resolve};
use anyhow::{Context, Error};
use std::{collections::HashMap, mem::take};
use std::collections::HashMap;
use swc_atoms::JsWord;
use swc_common::{
collections::AHashMap, sync::Lrc, FileName, Globals, Mark, SourceMap, SyntaxContext, GLOBALS,
Expand Down Expand Up @@ -185,7 +185,7 @@ where

#[cfg(feature = "concurrent")]
{
let scope = take(&mut self.scope);
let scope = std::mem::take(&mut self.scope);
rayon::spawn(move || drop(scope))
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
//!
//! ## Dependency version management
//!
//! `swc` has [swc_emcascript](https://docs.rs/swc_emcascript) and [swc_css](https://docs.rs/swc_css), which re-exports required modules.
//! `swc` has [swc_ecmascript](https://docs.rs/swc_emcascript) and [swc_css](https://docs.rs/swc_css), which re-exports required modules.
//!
//! ## Testing
//!
//! See [testing] and [swc_ecmc_transform_testing](https://docs.rs/swc_ecmc_transform_testing).
//! See [testing] and [swc_ecma_transform_testing](https://docs.rs/swc_ecmc_transform_testing).
//!
//! ## Custom javascript transforms
//!
Expand Down Expand Up @@ -544,7 +544,7 @@ impl Compiler {
.context("failed to emit module")?;
}
// Invalid utf8 is valid in javascript world.
String::from_utf8(buf).expect("invalid utf8 characeter detected")
String::from_utf8(buf).expect("invalid utf8 character detected")
};
let (code, map) = match source_map {
SourceMapsConfig::Bool(v) => {
Expand Down
2 changes: 1 addition & 1 deletion testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "testing"
repository = "https://github.com/swc-project/swc.git"
version = "0.14.1"
version = "0.14.2"

[dependencies]
ansi_term = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion testing/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "testing_macros"
repository = "https://github.com/swc-project/swc.git"
version = "0.2.2"
version = "0.2.3"

[lib]
proc-macro = true
Expand Down
13 changes: 10 additions & 3 deletions testing/macros/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Parse for Config {
}};
($inner:expr) => {{
panic!(
"{}\nnote: exclude() expectes one or more comma-separated \
"{}\nnote: exclude() expects one or more comma-separated \
regular expressions, like exclude(\".*\\\\.d\\\\.ts\") or \
exclude(\".*\\\\.d\\\\.ts\", \".*\\\\.tsx\")",
$inner
Expand All @@ -45,7 +45,7 @@ impl Parse for Config {
}

if list.nested.is_empty() {
fail!("empty exlclude()")
fail!("empty exclude()")
}

for token in list.nested.iter() {
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Parse for Config {
let expected = r#"#[fixture("fixture/**/*.ts", exclude("*\.d\.ts"))]"#;

unimplemented!(
"Exected something like {}\nGot wrong meta tag: {:?}",
"Expected something like {}\nGot wrong meta tag: {:?}",
expected,
meta,
)
Expand Down Expand Up @@ -131,6 +131,12 @@ pub fn expand(callee: &Ident, attr: Config) -> Result<Vec<ItemFn>, Error> {
if pattern.is_match(&path_str) {
continue 'add;
}

if cfg!(target_os = "windows") {
if pattern.is_match(&path_str.replace("\\", "/")) {
continue 'add;
}
}
}

let ignored = path.components().any(|c| match c {
Expand Down Expand Up @@ -161,6 +167,7 @@ pub fn expand(callee: &Ident, attr: Config) -> Result<Vec<ItemFn>, Error> {
#[test]
#[inline(never)]
#[ignore]
#[doc(hidden)]
fn test_ident() {
callee(::std::path::PathBuf::from(path_str));
}
Expand Down
2 changes: 1 addition & 1 deletion testing/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod fixture;
/// The function is allowed to return `Result` on error. If it's the case
///
///
/// ## Ignoreing a test
/// ## Ignoring a test
///
/// If the path to the file contains a component starts with `.` (dot), it will
/// be ignore. This convention is widely used in many projects (including other
Expand Down
2 changes: 1 addition & 1 deletion testing/macros/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ fn ignored(_path: PathBuf) {}
fn multiple(_path: PathBuf) {}

#[fixture("tests/simple/**/*", exclude(".*\\.tsx", ".*.d\\.ts"))]
fn exlucde(_path: PathBuf) {}
fn exclude(_path: PathBuf) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @target: ES5
// @noEmitHelpers: true
var x = function(async) {
return async;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import regeneratorRuntime from "regenerator-runtime";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
// @target: es2017
// @noEmitHelpers: true
var foo = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
var v;
return regeneratorRuntime.wrap(function _callee$(_ctx) {
while(1)switch(_ctx.prev = _ctx.next){
case 0:
;
case 1:
case "end":
return _ctx.stop();
}
}, _callee);
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import regeneratorRuntime from "regenerator-runtime";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg), value = info.value;
} catch (error) {
reject(error);
return;
}
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
}
!function(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(void 0);
});
};
}(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function(_ctx) {
for(;;)switch(_ctx.prev = _ctx.next){
case 0:
case 1:
case "end":
return _ctx.stop();
}
}, _callee);
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import regeneratorRuntime from "regenerator-runtime";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
// @target: es2017
// @noEmitHelpers: true
var foo = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_ctx) {
while(1)switch(_ctx.prev = _ctx.next){
case 0:
case "end":
return _ctx.stop();
}
}, _callee);
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import regeneratorRuntime from "regenerator-runtime";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg), value = info.value;
} catch (error) {
reject(error);
return;
}
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
}
!function(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(void 0);
});
};
}(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function(_ctx) {
for(;;)switch(_ctx.prev = _ctx.next){
case 0:
case "end":
return _ctx.stop();
}
}, _callee);
}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: es2017
// @noEmitHelpers: true
var f = function(_await) {
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @target: es2017
// @noEmitHelpers: true
function f(param) {
var _await = param === void 0 ? _await : param;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: es2017
// @noEmitHelpers: true
var _await = function() {
};
Loading

0 comments on commit 675c0e7

Please sign in to comment.