From 9bde66aed40e2ae95862a8a063c4a2a804a7a6ea Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Thu, 21 Nov 2024 18:40:10 +0000 Subject: [PATCH] chore(tests): apply formatting --- tests/cmp.luau | 164 ++++++++++++++++++++--------------------- tests/parse_valid.luau | 100 ++++++++++++------------- tests/tostring.luau | 66 ++++++++--------- 3 files changed, 165 insertions(+), 165 deletions(-) diff --git a/tests/cmp.luau b/tests/cmp.luau index b21006a..170e517 100644 --- a/tests/cmp.luau +++ b/tests/cmp.luau @@ -8,95 +8,95 @@ type Option = Option.Option local Semver = require("../lib") return function() - test.suite("Semver comparison tests", function() - test.case("Basic version comparisons", function() - local v1 = Semver.parse("1.2.3"):unwrap() - local v2 = Semver.parse("1.2.4"):unwrap() - local v3 = Semver.parse("1.3.0"):unwrap() - local v4 = Semver.parse("2.0.0"):unwrap() - local v5 = Semver.parse("2.1.0"):unwrap() - local v6 = Semver.parse("3.0.0"):unwrap() + test.suite("Semver comparison tests", function() + test.case("Basic version comparisons", function() + local v1 = Semver.parse("1.2.3"):unwrap() + local v2 = Semver.parse("1.2.4"):unwrap() + local v3 = Semver.parse("1.3.0"):unwrap() + local v4 = Semver.parse("2.0.0"):unwrap() + local v5 = Semver.parse("2.1.0"):unwrap() + local v6 = Semver.parse("3.0.0"):unwrap() - check.is_true(v1 < v2) - check.is_true(v2 < v3) - check.is_true(v3 < v4) - check.is_true(v4 < v5) - check.is_true(v5 < v6) - check.is_true(v1 <= v2) - check.is_true(v2 > v1) - check.is_true(v4 >= v3) - check.is_true(v6 > v1) - end) + check.is_true(v1 < v2) + check.is_true(v2 < v3) + check.is_true(v3 < v4) + check.is_true(v4 < v5) + check.is_true(v5 < v6) + check.is_true(v1 <= v2) + check.is_true(v2 > v1) + check.is_true(v4 >= v3) + check.is_true(v6 > v1) + end) - test.case("Equal version comparisons", function() - local v1 = Semver.parse("1.2.3"):unwrap() - local v2 = Semver.parse("1.2.3"):unwrap() - local v3 = Semver.parse("1.2.3"):unwrap() - local v4 = Semver.parse("1.2.3"):unwrap() + test.case("Equal version comparisons", function() + local v1 = Semver.parse("1.2.3"):unwrap() + local v2 = Semver.parse("1.2.3"):unwrap() + local v3 = Semver.parse("1.2.3"):unwrap() + local v4 = Semver.parse("1.2.3"):unwrap() - check.is_true(v1 == v2) - check.is_true(v2 == v3) - check.is_true(v3 == v4) - check.is_true(v1 <= v2) - check.is_true(v1 >= v2) - check.is_false(v1 < v2) - check.is_false(v1 > v2) - check.is_false(v3 > v4) - end) + check.is_true(v1 == v2) + check.is_true(v2 == v3) + check.is_true(v3 == v4) + check.is_true(v1 <= v2) + check.is_true(v1 >= v2) + check.is_false(v1 < v2) + check.is_false(v1 > v2) + check.is_false(v3 > v4) + end) - test.case("Prerelease version comparisons", function() - local v1 = Semver.parse("1.2.3-alpha.1"):unwrap() - local v2 = Semver.parse("1.2.3-alpha.2"):unwrap() - local v3 = Semver.parse("1.2.3-beta.1"):unwrap() - local v4 = Semver.parse("1.2.3"):unwrap() - local v5 = Semver.parse("1.2.3-rc.1"):unwrap() - local v6 = Semver.parse("1.2.3-rc.2"):unwrap() + test.case("Prerelease version comparisons", function() + local v1 = Semver.parse("1.2.3-alpha.1"):unwrap() + local v2 = Semver.parse("1.2.3-alpha.2"):unwrap() + local v3 = Semver.parse("1.2.3-beta.1"):unwrap() + local v4 = Semver.parse("1.2.3"):unwrap() + local v5 = Semver.parse("1.2.3-rc.1"):unwrap() + local v6 = Semver.parse("1.2.3-rc.2"):unwrap() - check.is_true(v1 < v2) - check.is_true(v2 < v3) - check.is_true(v3 < v4) - check.is_true(v3 < v5) - check.is_true(v5 < v6) - check.is_true(v6 < v4) - check.is_false(v4 < v1) - check.is_true(v4 > v3) - end) + check.is_true(v1 < v2) + check.is_true(v2 < v3) + check.is_true(v3 < v4) + check.is_true(v3 < v5) + check.is_true(v5 < v6) + check.is_true(v6 < v4) + check.is_false(v4 < v1) + check.is_true(v4 > v3) + end) - test.case("Build metadata comparisons", function() - local v1 = Semver.parse("1.2.3+build.1"):unwrap() - local v2 = Semver.parse("1.2.3+build.2"):unwrap() - local v3 = Semver.parse("1.2.3+build.123"):unwrap() - local v4 = Semver.parse("1.2.3+20230615"):unwrap() - local v5 = Semver.parse("1.2.3+exp.sha.5114f85"):unwrap() + test.case("Build metadata comparisons", function() + local v1 = Semver.parse("1.2.3+build.1"):unwrap() + local v2 = Semver.parse("1.2.3+build.2"):unwrap() + local v3 = Semver.parse("1.2.3+build.123"):unwrap() + local v4 = Semver.parse("1.2.3+20230615"):unwrap() + local v5 = Semver.parse("1.2.3+exp.sha.5114f85"):unwrap() - -- Build metadata should be ignored in comparisons - check.is_true(v1 == v2) - check.is_true(v2 == v3) - check.is_true(v3 == v4) - check.is_true(v4 == v5) - check.is_false(v1 < v2) - check.is_false(v2 > v3) - check.is_false(v4 > v5) - end) + -- Build metadata should be ignored in comparisons + check.is_true(v1 == v2) + check.is_true(v2 == v3) + check.is_true(v3 == v4) + check.is_true(v4 == v5) + check.is_false(v1 < v2) + check.is_false(v2 > v3) + check.is_false(v4 > v5) + end) - test.case("Complex version comparisons", function() - local v1 = Semver.parse("2.0.0-alpha.1+build.123"):unwrap() - local v2 = Semver.parse("2.0.0-beta.1+build.123"):unwrap() - local v3 = Semver.parse("2.0.0+build.123"):unwrap() - local v4 = Semver.parse("2.1.0-alpha.1"):unwrap() - local v5 = Semver.parse("2.1.0"):unwrap() - local v6 = Semver.parse("2.1.0-rc.1+build.999"):unwrap() - local v7 = Semver.parse("2.1.1-alpha.1+sha.xyz"):unwrap() + test.case("Complex version comparisons", function() + local v1 = Semver.parse("2.0.0-alpha.1+build.123"):unwrap() + local v2 = Semver.parse("2.0.0-beta.1+build.123"):unwrap() + local v3 = Semver.parse("2.0.0+build.123"):unwrap() + local v4 = Semver.parse("2.1.0-alpha.1"):unwrap() + local v5 = Semver.parse("2.1.0"):unwrap() + local v6 = Semver.parse("2.1.0-rc.1+build.999"):unwrap() + local v7 = Semver.parse("2.1.1-alpha.1+sha.xyz"):unwrap() - check.is_true(v1 < v2) - check.is_true(v2 < v3) - check.is_true(v3 < v4) - check.is_true(v4 < v5) - check.is_true(v4 < v6) - check.is_true(v6 < v5) - check.is_true(v5 < v7) - check.is_false(v5 < v1) - check.is_false(v7 < v6) - end) - end) + check.is_true(v1 < v2) + check.is_true(v2 < v3) + check.is_true(v3 < v4) + check.is_true(v4 < v5) + check.is_true(v4 < v6) + check.is_true(v6 < v5) + check.is_true(v5 < v7) + check.is_false(v5 < v1) + check.is_false(v7 < v6) + end) + end) end diff --git a/tests/parse_valid.luau b/tests/parse_valid.luau index 8842d4b..fa8225f 100644 --- a/tests/parse_valid.luau +++ b/tests/parse_valid.luau @@ -8,65 +8,65 @@ type Option = Option.Option local Semver = require("../lib") return function() - test.suite("Basic tests", function() - test.case("Semver creates valid version objects", function() - local res = Semver.parse("1.2.3-beta.1") - check.is_true(res:isOk()) + test.suite("Basic tests", function() + test.case("Semver creates valid version objects", function() + local res = Semver.parse("1.2.3-beta.1") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) - end) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) + end) - test.case("Semver handles prerelease versions", function() - local res = Semver.parse("1.2.3-beta.1") - check.is_true(res:isOk()) + test.case("Semver handles prerelease versions", function() + local res = Semver.parse("1.2.3-beta.1") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) - check.table.equal( - version.prerelease, - Option.Some({ - type = "beta", - ordinal = Option.Some(1), - }) - ) - end) + check.table.equal( + version.prerelease, + Option.Some({ + type = "beta", + ordinal = Option.Some(1), + }) + ) + end) - test.case("Semver handles build metadata", function() - local res = Semver.parse("1.2.3+build.123") - check.is_true(res:isOk()) + test.case("Semver handles build metadata", function() + local res = Semver.parse("1.2.3+build.123") + check.is_true(res:isOk()) - local version = res:unwrap() + local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) - check.table.equal(version.buildMetadata, Option.Some("build.123")) - end) + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) + check.table.equal(version.buildMetadata, Option.Some("build.123")) + end) - test.case("Semver handles prerelease versions with build metadata", function() - local res = Semver.parse("1.2.3-beta.1+build.123") - check.is_true(res:isOk()) + test.case("Semver handles prerelease versions with build metadata", function() + local res = Semver.parse("1.2.3-beta.1+build.123") + check.is_true(res:isOk()) - local version = res:unwrap() - check.equal(version.major, 1) - check.equal(version.minor, 2) - check.equal(version.patch, 3) + local version = res:unwrap() + check.equal(version.major, 1) + check.equal(version.minor, 2) + check.equal(version.patch, 3) - check.table.equal( - version.prerelease, - Option.Some({ - type = "beta", - ordinal = Option.Some(1), - }) - ) + check.table.equal( + version.prerelease, + Option.Some({ + type = "beta", + ordinal = Option.Some(1), + }) + ) - check.table.equal(version.buildMetadata, Option.Some("build.123")) - end) - end) + check.table.equal(version.buildMetadata, Option.Some("build.123")) + end) + end) end diff --git a/tests/tostring.luau b/tests/tostring.luau index 1ee058b..7d42650 100644 --- a/tests/tostring.luau +++ b/tests/tostring.luau @@ -1,33 +1,33 @@ -local frktest = require("@pkg/frktest") -local test = frktest.test -local check = frktest.assert.check - -local Option = require("../luau_packages/option") -type Option = Option.Option - -local Semver = require("../lib") - -return function() - test.suite("Stringification tests", function() - test.case("A parsed version when stringified should not change", function() - local versions = { - "1.2.3", - "1.0.0-alpha", - "2.3.4-beta.1", - "3.0.0-rc.1+build.123", - "4.5.6+sha.xyz", - "5.0.0-alpha.1+build.999", - "6.7.8-beta.2+exp.sha.5114f85", - "7.0.0-alpha.1", - "9.9.9+20230615", - } - - for _, version in versions do - local parsed = Semver.parse(version):unwrap() - local stringified = tostring(parsed) - - check.equal(stringified, version) - end - end) - end) -end +local frktest = require("@pkg/frktest") +local test = frktest.test +local check = frktest.assert.check + +local Option = require("../luau_packages/option") +type Option = Option.Option + +local Semver = require("../lib") + +return function() + test.suite("Stringification tests", function() + test.case("A parsed version when stringified should not change", function() + local versions = { + "1.2.3", + "1.0.0-alpha", + "2.3.4-beta.1", + "3.0.0-rc.1+build.123", + "4.5.6+sha.xyz", + "5.0.0-alpha.1+build.999", + "6.7.8-beta.2+exp.sha.5114f85", + "7.0.0-alpha.1", + "9.9.9+20230615", + } + + for _, version in versions do + local parsed = Semver.parse(version):unwrap() + local stringified = tostring(parsed) + + check.equal(stringified, version) + end + end) + end) +end