Skip to content

Commit

Permalink
chore: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake committed Mar 3, 2024
1 parent 470f823 commit e386d59
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion compiler/test/suites/numbers.re
Expand Up @@ -199,7 +199,61 @@ describe("numbers", ({test, testSkip}) => {
);

// well-formedness warnings
test("float32_fromNumber_warn1", ({expect}) => {
test("short_fromNumber_warn1", ({expect}) => {
expect.string(Warnings.message(FromNumberLiteral(Uint8, "Uint8", "2"))).
toMatch(
"2us",
)
});
test("short_fromNumber_warn2", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Uint16, "Uint16", "2")),
).
toMatch(
"2uS",
)
});
test("short_fromNumber_warn3", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Uint32, "Uint32", "2")),
).
toMatch(
"2ul",
)
});
test("short_fromNumber_warn4", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Uint64, "Uint64", "2")),
).
toMatch(
"2uL",
)
});
test("short_fromNumber_warn5", ({expect}) => {
expect.string(Warnings.message(FromNumberLiteral(Int8, "Int8", "2"))).
toMatch(
"2s",
)
});
test("short_fromNumber_warn6", ({expect}) => {
expect.string(Warnings.message(FromNumberLiteral(Int16, "Int16", "2"))).
toMatch(
"2S",
)
});
test("short_fromNumber_warn7", ({expect}) => {
expect.string(Warnings.message(FromNumberLiteral(Int32, "Int32", "2"))).
toMatch(
"2l",
)
});
test("short_fromNumber_warn8", ({expect}) => {
expect.string(Warnings.message(FromNumberLiteral(Int64, "Int64", "2"))).
toMatch(
"2L",
)
});
test("float32_fromNumber_warn9", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Float32, "Float32", "5")),
).
Expand Down Expand Up @@ -247,4 +301,28 @@ describe("numbers", ({test, testSkip}) => {
"5.5d",
)
});
test("rational_fromNumber_warn1", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Rational, "Rational", "2")),
).
toMatch(
"2/1r",
)
});
test("rational_fromNumber_warn2", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(Rational, "Rational", "2/4")),
).
toMatch(
"2/4r",
)
});
test("bigint_fromNumber_warn1", ({expect}) => {
expect.string(
Warnings.message(FromNumberLiteral(BigInt, "Bigint", "2")),
).
toMatch(
"2t",
)
});
});

0 comments on commit e386d59

Please sign in to comment.