Skip to content

Commit 673928b

Browse files
committed
refactored new tests for consistency
1 parent 959d4b8 commit 673928b

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

ark/regex/__tests__/regex.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ contextualize(() => {
296296
attest<Regex<"" | "a", {}>>(S)
297297
})
298298

299+
it("leading zeroes", () => {
300+
const S = regex("^a{002}$")
301+
attest<Regex<"aa">>(S)
302+
})
303+
299304
it("falls back to literal for missing min", () => {
300305
const r = regex("^a{,2}$")
301306
attest<Regex<"a{,2}", {}>>(r).type.toString.snap('Regex<"a{,2}", {}>')
@@ -313,6 +318,21 @@ contextualize(() => {
313318
)
314319
})
315320

321+
it("falls back to literal for negative number", () => {
322+
const S = regex("^a{-1}$")
323+
attest<Regex<"a{-1}">>(S)
324+
})
325+
326+
it("falls back to literal for decimal number", () => {
327+
const S = regex("^a{1.5}$")
328+
attest<Regex<`a{1${string}5}`>>(S)
329+
})
330+
331+
it("falls back to literal for spaced number", () => {
332+
const S = regex("^a{ 1}$")
333+
attest<Regex<"a{ 1}">>(S)
334+
})
335+
316336
it("${string} does not duplicate when quantified", () => {
317337
const r = regex("^.{5,10}$")
318338
attest<Regex<string, {}>>(r).type.toString.snap("Regex<string, {}>")
@@ -335,26 +355,6 @@ contextualize(() => {
335355
attest<Regex<"aa" | "ab" | "ba" | "bb", { captures: ["a"] | ["b"] }>>(S)
336356
})
337357

338-
it("negative quantifier as literal", () => {
339-
const S = regex("^a{-1}$")
340-
attest<Regex<"a{-1}">>(S)
341-
})
342-
343-
it("decimal quantifier as literal", () => {
344-
const S = regex("^a{1.5}$")
345-
attest<Regex<`a{1${string}5}`>>(S)
346-
})
347-
348-
it("whitespace quantifier as literal", () => {
349-
const S = regex("^a{ 1}$")
350-
attest<Regex<"a{ 1}">>(S)
351-
})
352-
353-
it("treated quantifier leading zeroes", () => {
354-
const S = regex("^a{002}$")
355-
attest<Regex<"aa">>(S)
356-
})
357-
358358
it("unmatched", () => {
359359
// @ts-expect-error
360360
attest(() => regex("{2}")).type.errors(

0 commit comments

Comments
 (0)