From 53879a0d1b088e0047aadf3bc7c4cbd607e9c192 Mon Sep 17 00:00:00 2001 From: buildingisfun23 Date: Sun, 12 Apr 2026 19:58:11 -0700 Subject: [PATCH 1/2] test: add semver assertions for numeric context values Add Float and Integer context type coverage to the semver test suite: - Add Float rows (1 and 1.2) to the partial version handling scenario - Add semver-numeric-context-flag targeting rule using '>' operator - Add new 'numeric context value handling' scenario asserting Float and Integer context values compare correctly against string semver targets Closes #237 Signed-off-by: buildingisfun23 --- evaluator/flags/testkit-flags.json | 8 ++++++++ evaluator/gherkin/semver.feature | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/evaluator/flags/testkit-flags.json b/evaluator/flags/testkit-flags.json index 1db5f14..8f5e379 100644 --- a/evaluator/flags/testkit-flags.json +++ b/evaluator/flags/testkit-flags.json @@ -521,6 +521,14 @@ "if": [{"sem_ver": [{"var": "version"}, "=", "1.0.0+build"]}, "match", "no-match"] } }, + "semver-numeric-context-flag": { + "state": "ENABLED", + "variants": { "match": "match", "no-match": "no-match" }, + "defaultVariant": "no-match", + "targeting": { + "if": [{"sem_ver": [{"var": "version"}, ">", "1.1"]}, "match", "no-match"] + } + }, "ref-whitespace-compact-flag": { "state": "ENABLED", "variants": { diff --git a/evaluator/gherkin/semver.feature b/evaluator/gherkin/semver.feature index 18c5130..7d17cbd 100644 --- a/evaluator/gherkin/semver.feature +++ b/evaluator/gherkin/semver.feature @@ -73,8 +73,25 @@ Feature: Evaluator semantic version operator | 1.0 | String | match | | 1 | String | match | | 1 | Integer | match | + | 1 | Float | match | + | 1.2 | Float | match | | 2.0.0 | String | no-match | + @semver-edge-cases @semver-numeric-context + Scenario Outline: numeric context value handling + Given an evaluator + And a String-flag with key "semver-numeric-context-flag" and a fallback value "fallback" + And a context containing a key "version", with type "" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | type | value | + | 1.2 | Float | match | + | 1.1 | Float | no-match | + | 2 | Integer | match | + | 1 | Integer | no-match | + | 1.2 | String | match | + @semver-edge-cases @semver-build-metadata Scenario Outline: build metadata ignored in comparison Given an evaluator From 9978adc4d9260429e30707285d9448b2af678e83 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 13 Apr 2026 11:18:16 -0400 Subject: [PATCH 2/2] fixup: add to targeting, naming tweaks Signed-off-by: Todd Baert --- evaluator/gherkin/semver.feature | 4 ++-- flags/custom-ops.json | 14 ++++++++++++++ gherkin/targeting.feature | 18 +++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/evaluator/gherkin/semver.feature b/evaluator/gherkin/semver.feature index 7d17cbd..1b136f2 100644 --- a/evaluator/gherkin/semver.feature +++ b/evaluator/gherkin/semver.feature @@ -60,7 +60,7 @@ Feature: Evaluator semantic version operator | 2.0.0 | no-match | @semver-edge-cases @semver-partial-version - Scenario Outline: partial version handling + Scenario Outline: partial version string handling Given an evaluator And a String-flag with key "semver-partial-version-flag" and a fallback value "fallback" And a context containing a key "version", with type "" and with value "" @@ -78,7 +78,7 @@ Feature: Evaluator semantic version operator | 2.0.0 | String | no-match | @semver-edge-cases @semver-numeric-context - Scenario Outline: numeric context value handling + Scenario Outline: numeric context value coercion Given an evaluator And a String-flag with key "semver-numeric-context-flag" and a fallback value "fallback" And a context containing a key "version", with type "" and with value "" diff --git a/flags/custom-ops.json b/flags/custom-ops.json index 27d1c96..c2334a0 100644 --- a/flags/custom-ops.json +++ b/flags/custom-ops.json @@ -341,6 +341,20 @@ ] } }, + "semver-numeric-context-flag": { + "state": "ENABLED", + "variants": { + "match": "match", + "no-match": "no-match" + }, + "defaultVariant": "no-match", + "targeting": { + "if": [ + {"sem_ver": [{"var": "version"}, ">", "1.1"]}, + "match", "no-match" + ] + } + }, "semver-build-metadata-flag": { "state": "ENABLED", "variants": { diff --git a/gherkin/targeting.feature b/gherkin/targeting.feature index ec90364..2e23dd1 100644 --- a/gherkin/targeting.feature +++ b/gherkin/targeting.feature @@ -283,7 +283,7 @@ Feature: Targeting rules | 2.0.0 | no-match | @semver @semver-edge-cases @semver-partial-version - Scenario Outline: sem_ver partial version handling + Scenario Outline: sem_ver partial version string handling Given a String-flag with key "semver-partial-version-flag" and a default value "fallback" And a context containing a key "version", with type "" and with value "" When the flag was evaluated with details @@ -295,8 +295,24 @@ Feature: Targeting rules | 1.0 | String | match | | 1 | String | match | | 1 | Integer | match | + | 1 | Float | match | + | 1.2 | Float | match | | 2.0.0 | String | no-match | + @semver @semver-edge-cases @semver-numeric-context + Scenario Outline: sem_ver numeric context value coercion + Given a String-flag with key "semver-numeric-context-flag" and a default value "fallback" + And a context containing a key "version", with type "" and with value "" + When the flag was evaluated with details + Then the resolved details value should be "" + Examples: + | version | type | value | + | 1.2 | Float | match | + | 1.1 | Float | no-match | + | 2 | Integer | match | + | 1 | Integer | no-match | + | 1.2 | String | match | + @semver @semver-edge-cases @semver-build-metadata Scenario Outline: sem_ver build metadata ignored Given a String-flag with key "semver-build-metadata-flag" and a default value "fallback"