From 3ffc8625ba2c7b25f70347000f768af6e4ac1e6f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 28 Nov 2025 05:08:55 +0100 Subject: [PATCH] repro large variant timeout for https://github.com/rescript-lang/rescript/pull/8039 --- tests/analysis_tests/perf_test/Makefile | 7 +++ tests/analysis_tests/perf_test/package.json | 11 ++++ tests/analysis_tests/perf_test/rescript.json | 10 ++++ tests/analysis_tests/perf_test/src/Player.js | 18 ++++++ tests/analysis_tests/perf_test/src/Player.res | 58 +++++++++++++++++++ .../perf_test/src/Thundershock.js | 10 ++++ .../perf_test/src/Thundershock.res | 15 +++++ yarn.lock | 8 +++ 8 files changed, 137 insertions(+) create mode 100644 tests/analysis_tests/perf_test/Makefile create mode 100644 tests/analysis_tests/perf_test/package.json create mode 100644 tests/analysis_tests/perf_test/rescript.json create mode 100644 tests/analysis_tests/perf_test/src/Player.js create mode 100644 tests/analysis_tests/perf_test/src/Player.res create mode 100644 tests/analysis_tests/perf_test/src/Thundershock.js create mode 100644 tests/analysis_tests/perf_test/src/Thundershock.res diff --git a/tests/analysis_tests/perf_test/Makefile b/tests/analysis_tests/perf_test/Makefile new file mode 100644 index 0000000000..4b0f5c6ad7 --- /dev/null +++ b/tests/analysis_tests/perf_test/Makefile @@ -0,0 +1,7 @@ +SHELL = /bin/bash + +build: + yarn build + +clean: + yarn clean diff --git a/tests/analysis_tests/perf_test/package.json b/tests/analysis_tests/perf_test/package.json new file mode 100644 index 0000000000..a00f363b63 --- /dev/null +++ b/tests/analysis_tests/perf_test/package.json @@ -0,0 +1,11 @@ +{ + "name": "perf_test", + "private": true, + "scripts": { + "build": "rescript-legacy build", + "clean": "rescript-legacy clean" + }, + "dependencies": { + "rescript": "workspace:^" + } +} diff --git a/tests/analysis_tests/perf_test/rescript.json b/tests/analysis_tests/perf_test/rescript.json new file mode 100644 index 0000000000..4a05e2b2b3 --- /dev/null +++ b/tests/analysis_tests/perf_test/rescript.json @@ -0,0 +1,10 @@ +{ + "name": "test", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "suffix": ".res.js" +} diff --git a/tests/analysis_tests/perf_test/src/Player.js b/tests/analysis_tests/perf_test/src/Player.js new file mode 100644 index 0000000000..7310ca2090 --- /dev/null +++ b/tests/analysis_tests/perf_test/src/Player.js @@ -0,0 +1,18 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +let Thundershock = require("./Thundershock.js"); + +function make() { + key => { + let isYAxis = (3).direction.y !== 0; + if (key === "space" && isYAxis) { + Thundershock.cast(3); + return; + } + }.onKeyRelease(); + return 3; +} + +exports.make = make; +/* No side effect */ diff --git a/tests/analysis_tests/perf_test/src/Player.res b/tests/analysis_tests/perf_test/src/Player.res new file mode 100644 index 0000000000..7aabbd3b68 --- /dev/null +++ b/tests/analysis_tests/perf_test/src/Player.res @@ -0,0 +1,58 @@ +@unboxed +type key = + // | @as("f2") F2 + // | @as("f3") F3 + // | @as("f4") F4 + // | @as("f5") F5 + // | @as("f6") F6 + // | @as("f7") F7 + // | @as("f8") F8 + // | @as("f9") F9 + | @as("f10") F10 + | @as("l") L + | @as("m") M + | @as("n") N + | @as("o") O + | @as("p") P + | @as("q") Q + | @as("r") R + | @as("s") S + | @as("t") T + | @as("u") U + | @as("v") V + | @as("w") W + | @as("x") X + | @as("space") Space + | @as("left") Left + | @as("right") Right + | @as("up") Up + | @as("down") Down + | @as("escape") Escape + | @as("backspace") Backspace + | @as("enter") Enter + | @as("tab") Tab + | @as("control") Control + | @as("alt") Alt + | @as("meta") Meta + | @as("shift") Shift + | @as("string") String(string) + +@send +external onKeyRelease: (key => unit) => unit = "onKeyRelease" + +let make = () => { + let gameObj: Thundershock.t = Obj.magic(3) + + onKeyRelease(key => { + let isYAxis = !(gameObj.direction.y == 0.) + switch key { + | Space => + if isYAxis { + Thundershock.cast(gameObj)->ignore + } + | _ => () + } + }) + + gameObj +} diff --git a/tests/analysis_tests/perf_test/src/Thundershock.js b/tests/analysis_tests/perf_test/src/Thundershock.js new file mode 100644 index 0000000000..7f30290132 --- /dev/null +++ b/tests/analysis_tests/perf_test/src/Thundershock.js @@ -0,0 +1,10 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + + +function cast(param) { + +} + +exports.cast = cast; +/* No side effect */ diff --git a/tests/analysis_tests/perf_test/src/Thundershock.res b/tests/analysis_tests/perf_test/src/Thundershock.res new file mode 100644 index 0000000000..27dca65a1c --- /dev/null +++ b/tests/analysis_tests/perf_test/src/Thundershock.res @@ -0,0 +1,15 @@ +type team = Player | Opponent + +type vec2 = { + mutable x: float, + mutable y: float, +} + + +type t = {mutable direction: vec2} + + +let cast = (_: t) => { + () +} + diff --git a/yarn.lock b/yarn.lock index 81e1630eae..e81d2c449e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2415,6 +2415,14 @@ __metadata: languageName: node linkType: hard +"perf_test@workspace:tests/analysis_tests/perf_test": + version: 0.0.0-use.local + resolution: "perf_test@workspace:tests/analysis_tests/perf_test" + dependencies: + rescript: "workspace:^" + languageName: unknown + linkType: soft + "picocolors@npm:^1.0.0, picocolors@npm:^1.1.1": version: 1.1.1 resolution: "picocolors@npm:1.1.1"