diff --git a/CHANGELOG.md b/CHANGELOG.md index 5426a2438cb..e53d75d04c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ #### :house: Internal +- Forward-port integer range pattern regression coverage from v12 to v13. https://github.com/rescript-lang/rescript/pull/8718 - Remove the unused `res.iflet` encoding of `if let`, which the parser always rejects with a syntax error suggesting a `switch`. The error is unchanged. https://github.com/rescript-lang/rescript/pull/8741 - Represent variant spread patterns (`...t`) with a dedicated `Ppat_variant_spread` parsetree node instead of `Ppat_type` with a `res.patVariantSpread` attribute, which remains only in the PPX wire representation. https://github.com/rescript-lang/rescript/pull/8742 - Remove the obsolete `res.ternary` and `JSX` attributes from the formatter's internal attribute filters and merge the filters into one. https://github.com/rescript-lang/rescript/pull/8740 diff --git a/tests/tests/src/or_pattern_int_range_test.mjs b/tests/tests/src/or_pattern_int_range_test.mjs new file mode 100644 index 00000000000..1864d567b8e --- /dev/null +++ b/tests/tests/src/or_pattern_int_range_test.mjs @@ -0,0 +1,36 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Test_utils from "./test_utils.mjs"; + +function isRetriable(error) { + let match = error.status; + return !(match > 504 || match < 502); +} + +Mocha.describe("Or_pattern_int_range_test", () => { + Mocha.test("int range on record field", () => Test_utils.eq("File \"or_pattern_int_range_test.res\", line 15, characters 6-13", [ + 404, + 500, + 501, + 502, + 503, + 504, + 505 + ].map(status => isRetriable({ + status: status + })), [ + false, + false, + false, + true, + true, + true, + false + ])); +}); + +export { + isRetriable, +} +/* Not a pure module */ diff --git a/tests/tests/src/or_pattern_int_range_test.res b/tests/tests/src/or_pattern_int_range_test.res new file mode 100644 index 00000000000..90735ac135e --- /dev/null +++ b/tests/tests/src/or_pattern_int_range_test.res @@ -0,0 +1,20 @@ +open Mocha +open Test_utils + +type response = {status: int} + +let isRetriable = error => + switch error { + | {status: 502 | 503 | 504} => true + | _ => false + } + +describe(__MODULE__, () => { + test("int range on record field", () => { + eq( + __LOC__, + [404, 500, 501, 502, 503, 504, 505]->Array.map(status => isRetriable({status: status})), + [false, false, false, true, true, true, false], + ) + }) +})