Skip to content

Commit

Permalink
Disable let/const babel plugin and co
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Mar 15, 2021
1 parent 4e9aeae commit a0eb5ff
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 133 deletions.
6 changes: 3 additions & 3 deletions js/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
"transform-es2015-literals",
"transform-es2015-function-name",
[]interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}},
"transform-es2015-block-scoped-functions",
// "transform-es2015-block-scoped-functions", // in goja
[]interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}},
"transform-es2015-object-super",
// "transform-es2015-shorthand-properties", // in goja
Expand All @@ -53,11 +53,11 @@ var (
// "transform-es2015-for-of", // in goja
// "transform-es2015-sticky-regex", // in goja
// "transform-es2015-unicode-regex", // in goja
"check-es2015-constants",
// "check-es2015-constants", // in goja
[]interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}},
"transform-es2015-parameters",
[]interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}},
"transform-es2015-block-scoping", // let/const which particularly slow on big inputs
// "transform-es2015-block-scoping", // in goja
// "transform-es2015-typeof-symbol", // in goja
// all the other module plugins are just dropped
[]interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}},
Expand Down
2 changes: 1 addition & 1 deletion js/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestTransform(t *testing.T) {
` return a + b;`,
`};`,
``,
`var res = add(1, 2);`,
`let res = add(1, 2);`,
}, "\n"), src)
// assert.Equal(t, 3, srcmap.Version)
// assert.Equal(t, "test.js", srcmap.File)
Expand Down
32 changes: 21 additions & 11 deletions js/modules/k6/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,22 +1184,25 @@ func TestRequestAndBatch(t *testing.T) {
})
t.Run("GET", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
["GET", "HTTPBIN_URL/"],
["GET", "HTTPBIN_IP_URL/"],
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + res[key].status); }
if (res[key].url != reqs[key][1]) { throw new Error("wrong url: " + res[key].url); }
}`))
}
}`))
require.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_IP_URL/"), "", 200, "")

t.Run("Tagged", func(t *testing.T) {
_, err := runES6String(t, rt, sr(`
{
let fragment = "get";
let reqs = [
["GET", http.url`+"`"+`HTTPBIN_URL/${fragment}`+"`"+`],
Expand All @@ -1209,7 +1212,8 @@ func TestRequestAndBatch(t *testing.T) {
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key][1].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key][1].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/get"), sr("HTTPBIN_URL/${}"), 200, "")
Expand All @@ -1218,22 +1222,25 @@ func TestRequestAndBatch(t *testing.T) {

t.Run("Shorthand", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
"HTTPBIN_URL/",
"HTTPBIN_IP_URL/",
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key]) { throw new Error("wrong url: " + key + ": " + res[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_IP_URL/"), "", 200, "")

t.Run("Tagged", func(t *testing.T) {
_, err := runES6String(t, rt, sr(`
{
let fragment = "get";
let reqs = [
http.url`+"`"+`HTTPBIN_URL/${fragment}`+"`"+`,
Expand All @@ -1243,7 +1250,8 @@ func TestRequestAndBatch(t *testing.T) {
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/get"), sr("HTTPBIN_URL/${}"), 200, "")
Expand All @@ -1253,15 +1261,17 @@ func TestRequestAndBatch(t *testing.T) {

t.Run("ObjectForm", func(t *testing.T) {
_, err := rt.RunString(sr(`
var reqs = [
{
let reqs = [
{ method: "GET", url: "HTTPBIN_URL/" },
{ url: "HTTPBIN_IP_URL/", method: "GET"},
];
var res = http.batch(reqs);
let res = http.batch(reqs);
for (var key in res) {
if (res[key].status != 200) { throw new Error("wrong status: " + key + ": " + res[key].status); }
if (res[key].url != reqs[key].url) { throw new Error("wrong url: " + key + ": " + res[key].url + " != " + reqs[key].url); }
}`))
}
}`))
assert.NoError(t, err)
bufSamples := stats.GetBufferedSamples(samples)
assertRequestMetricsEmitted(t, bufSamples, "GET", sr("HTTPBIN_URL/"), "", 200, "")
Expand Down
Loading

0 comments on commit a0eb5ff

Please sign in to comment.