Skip to content

Commit 0c08bfa

Browse files
committed
test(syntax): use regex literal in test files
necessary to pass syntax roundtrip test since printing has changed
1 parent 23cbe82 commit 0c08bfa

File tree

17 files changed

+48
-49
lines changed

17 files changed

+48
-49
lines changed

jscomp/syntax/tests/idempotency/nook-exchange/App.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let make = () => {
6464
let url = ReasonReactRouter.useUrl()
6565
let (showLogin, setShowLogin) = React.useState(() => false)
6666
let itemDetails = {
67-
let result = url.hash |> Js.Re.exec_(%re("/i(-?\d+)(:(\d+))?/g"))
67+
let result = url.hash |> Js.Re.exec_(/i(-?\d+)(:(\d+))?/g)
6868
switch result {
6969
| Some(match_) =>
7070
let captures = Js.Re.captures(match_)

jscomp/syntax/tests/idempotency/nook-exchange/Emoji.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module Styles = {
3131
let emoji = style(list{verticalAlign(#bottom), position(relative), top(px(-2))})
3232
}
3333

34-
let emojiRegex = %re(`/(^|\\s)(\\:[a-zA-Z0-9-_+]+\\:)/g`)
34+
let emojiRegex = /(^|\s)(\:[a-zA-Z0-9-_+]+\:)/g
3535

3636
let parseText = (text: string): React.element => {
3737
let children = []

jscomp/syntax/tests/idempotency/nook-exchange/ImportPage.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ let process = value => {
654654
let resultMap = Js.Dict.empty()
655655
let missingQueries = []
656656
rows->Array.forEach(row => {
657-
let result = row |> Js.Re.exec_(%re("/(.*?) \[(.*?)\]$/g"))
657+
let result = row |> Js.Re.exec_(/(.*?) \[(.*?)\]$/g)
658658
let itemWithVariant = switch result {
659659
| Some(match_) =>
660660
let captures = Js.Re.captures(match_)

jscomp/syntax/tests/idempotency/nook-exchange/Item.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let loadTranslation: (string, Js.Json.t => unit) => unit = %raw(`function(langua
8282

8383
exception UnexpectedType(string)
8484

85-
let spaceRegex = %re("/\\s/g")
85+
let spaceRegex = /\s/g
8686

8787
exception Unexpected
8888
let jsonToItems = (json: Js.Json.t) => {

jscomp/syntax/tests/idempotency/nook-exchange/ItemFilters.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ let doesItemMatchCategory = (~item: Item.t, ~category: string) =>
206206
}
207207

208208
let removeAccents = str =>
209-
str |> Js.String.normalizeByForm("NFD") |> Js.String.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
209+
str |> Js.String.normalizeByForm("NFD") |> Js.String.replaceByRe(/[\u0300-\u036f]/g, "")
210210

211211
let doesItemMatchFilters = (~item: Item.t, ~filters: t) =>
212212
switch filters.text {
@@ -218,7 +218,7 @@ let doesItemMatchFilters = (~item: Item.t, ~filters: t) =>
218218
| None => false
219219
} || {
220220
let fragments =
221-
(textLower |> Js.String.splitByRe(%re(`/[\\s-]+/`)))->Belt.Array.keepMap(x => x)
221+
(textLower |> Js.String.splitByRe(/[\s-]+/))->Belt.Array.keepMap(x => x)
222222
fragments->Belt.Array.every(fragment =>
223223
Js.String.toLowerCase(Item.getName(item))
224224
|> removeAccents
@@ -253,8 +253,8 @@ let compareArrays = (a, b) => {
253253

254254
let compareItemsABC = (a: Item.t, b: Item.t) => {
255255
// hack to sort "wooden-" before "wooden "
256-
let aName = Item.getName(a) |> Js.String.replaceByRe(%re("/-/g"), " ")
257-
let bName = Item.getName(b) |> Js.String.replaceByRe(%re("/-/g"), " ")
256+
let aName = Item.getName(a) |> Js.String.replaceByRe(/-/g, " ")
257+
let bName = Item.getName(b) |> Js.String.replaceByRe(/-/g, " ")
258258
int_of_float(Js.String.localeCompare(bName, aName))
259259
}
260260
let compareItemsSellPriceDesc = (a: Item.t, b: Item.t) =>
@@ -798,7 +798,7 @@ let make = (
798798
| "Escape" =>
799799
let url = ReasonReactRouter.dangerouslyGetInitialUrl()
800800
// don't trigger if ItemDetailOverlay is shown
801-
if !(url.hash |> Js.Re.test_(%re("/i(-?\d+)(:(\d+))?/g"))) {
801+
if !(url.hash |> Js.Re.test_(/i(-?\d+)(:(\d+))?/g)) {
802802
onChange({...filters, text: ""})
803803
}
804804
| "/" =>

jscomp/syntax/tests/idempotency/nook-exchange/UserStore.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ let toggleCatalogCheckboxSetting = (~enabled) => {
477477
)
478478
}
479479

480-
let errorQuotationMarksRegex = %re(`/^"(.*)"$/`)
480+
let errorQuotationMarksRegex = /^"(.*)"$/
481481
let register = (~username, ~email, ~password) =>
482482
%Repromise.JsExn({
483483
let response = Fetch.fetchWithInit(

jscomp/syntax/tests/idempotency/pupilfirst/questions/QuestionsShow__QuestionEditor.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ module UpdateQuestionError = {
183183
let handleResponseCB = (id, title) => {
184184
let window = Webapi.Dom.window
185185
let parameterizedTitle =
186-
title |> Js.String.toLowerCase |> Js.String.replaceByRe(%re("/[^0-9a-zA-Z]+/gi"), "-")
186+
title |> Js.String.toLowerCase |> Js.String.replaceByRe(/[^0-9a-zA-Z]+/gi, "-")
187187
let redirectPath = "/questions/" ++ (id ++ ("/" ++ parameterizedTitle))
188188
redirectPath |> Webapi.Dom.Window.setLocation(window)
189189
}

jscomp/syntax/tests/idempotency/pupilfirst/schools/CurriculumEditor__ContentBlockCreator.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ let updateEmbedUrl = (send, event) => {
292292
}
293293

294294
let embedUrlRegexes = [
295-
%re("/https:\\/\\/.*slideshare\\.net/"),
296-
%re("/https:\\/\\/.*vimeo\\.com/"),
297-
%re("/https:\\/\\/.*youtube\\.com/"),
298-
%re("/https:\\/\\/.*youtu\\.be/"),
295+
/https:\/\/.*slideshare\.net/,
296+
/https:\/\/.*vimeo\.com/,
297+
/https:\/\/.*youtube\.com/,
298+
/https:\/\/.*youtu\.be/,
299299
]
300300

301301
let validEmbedUrl = url => Belt.Array.some(embedUrlRegexes, regex => regex->Js.Re.test_(url))

jscomp/syntax/tests/idempotency/pupilfirst/schools/SA_Coaches_CoachEditor.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ let updateEmail = (send, email) => send(UpdateEmail(email, email |> emailInvalid
9494
let updateTitle = (send, title) => send(UpdateTitle(title, title |> nameOrTitleInvalid))
9595

9696
let updateLinkedInUrl = (send, linkedinUrl) => {
97-
let regex = %re(`/(https?)?:?(\\/\\/)?(([w]{3}||\\w\\w)\\.)?linkedin.com(\\w+:{0,1}\\w*@)?(\\S+)(:([0-9])+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/`)
97+
let regex = /(https?)?:?(\/\/)?(([w]{3}||\w\w)\.)?linkedin.com(\w+:{0,1}\w*@)?(\S+)(:([0-9])+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
9898
let hasError = linkedinUrl |> String.length < 1 ? false : !Js.Re.test_(regex, linkedinUrl)
9999
send(UpdateLinkedInUrl(linkedinUrl, hasError))
100100
}

jscomp/syntax/tests/idempotency/pupilfirst/schools/StudentsEditor__StudentInfoForm.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let updateName = (send, name) => {
2929
}
3030

3131
let updateEmail = (send, email) => {
32-
let regex = %re(`/.+@.+\\..+/i`)
32+
let regex = /.+@.+\..+/i
3333
let hasError = !Js.Re.test_(regex, email)
3434
send(UpdateEmail(email, hasError))
3535
}

0 commit comments

Comments
 (0)