-
-
Notifications
You must be signed in to change notification settings - Fork 603
fix(tester): correct edition mapping for ES16 #5146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -600,6 +600,7 @@ struct VersionedStats { | |
| es13: Statistics, | ||
| es14: Statistics, | ||
| es15: Statistics, | ||
| es16: Statistics, | ||
| } | ||
|
|
||
| impl<'de> Deserialize<'de> for VersionedStats { | ||
|
|
@@ -622,6 +623,8 @@ impl<'de> Deserialize<'de> for VersionedStats { | |
| es14: Option<Statistics>, | ||
| #[serde(default)] | ||
| es15: Option<Statistics>, | ||
| #[serde(default)] | ||
| es16: Option<Statistics>, | ||
| } | ||
|
|
||
| let inner = Inner::deserialize(deserializer)?; | ||
|
|
@@ -638,9 +641,11 @@ impl<'de> Deserialize<'de> for VersionedStats { | |
| es13, | ||
| es14, | ||
| es15, | ||
| es16, | ||
| } = inner; | ||
| let es14 = es14.unwrap_or(es13); | ||
| let es15 = es15.unwrap_or(es14); | ||
| let es16 = es16.unwrap_or(es15); | ||
|
|
||
| Ok(Self { | ||
| es5, | ||
|
|
@@ -654,6 +659,7 @@ impl<'de> Deserialize<'de> for VersionedStats { | |
| es13, | ||
| es14, | ||
| es15, | ||
| es16, | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -684,6 +690,7 @@ impl VersionedStats { | |
| SpecEdition::ES13 => self.es13, | ||
| SpecEdition::ES14 => self.es14, | ||
| SpecEdition::ES15 => self.es15, | ||
| SpecEdition::ES16 => self.es16, | ||
| SpecEdition::ESNext => return None, | ||
| }; | ||
| Some(stats) | ||
|
|
@@ -704,6 +711,7 @@ impl VersionedStats { | |
| SpecEdition::ES13 => &mut self.es13, | ||
| SpecEdition::ES14 => &mut self.es14, | ||
| SpecEdition::ES15 => &mut self.es15, | ||
| SpecEdition::ES16 => &mut self.es16, | ||
| SpecEdition::ESNext => return None, | ||
| }; | ||
| Some(stats) | ||
|
|
@@ -726,6 +734,7 @@ impl Add for VersionedStats { | |
| es13: self.es13 + rhs.es13, | ||
| es14: self.es14 + rhs.es14, | ||
| es15: self.es15 + rhs.es15, | ||
| es16: self.es16 + rhs.es16, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -743,6 +752,66 @@ impl AddAssign for VersionedStats { | |
| self.es13 += rhs.es13; | ||
| self.es14 += rhs.es14; | ||
| self.es15 += rhs.es15; | ||
| self.es16 += rhs.es16; | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::{SpecEdition, Statistics, VersionedStats}; | ||
|
|
||
| fn mark_passed(entry: &mut Statistics) { | ||
| entry.total += 1; | ||
| entry.passed += 1; | ||
| } | ||
|
|
||
| #[test] | ||
| fn deserializes_es16_from_older_results() { | ||
| let stats: VersionedStats = serde_json::from_value(serde_json::json!({ | ||
| "es5": {"t": 1, "o": 1, "i": 0, "p": 0}, | ||
| "es6": {"t": 2, "o": 2, "i": 0, "p": 0}, | ||
| "es7": {"t": 3, "o": 3, "i": 0, "p": 0}, | ||
| "es8": {"t": 4, "o": 4, "i": 0, "p": 0}, | ||
| "es9": {"t": 5, "o": 5, "i": 0, "p": 0}, | ||
| "es10": {"t": 6, "o": 6, "i": 0, "p": 0}, | ||
| "es11": {"t": 7, "o": 7, "i": 0, "p": 0}, | ||
| "es12": {"t": 8, "o": 8, "i": 0, "p": 0}, | ||
| "es13": {"t": 9, "o": 9, "i": 0, "p": 0}, | ||
| "es14": {"t": 10, "o": 10, "i": 0, "p": 0}, | ||
| "es15": {"t": 11, "o": 11, "i": 0, "p": 0} | ||
| })) | ||
| .expect("older result schema should deserialize"); | ||
|
|
||
| let es15 = stats | ||
| .get(SpecEdition::ES15) | ||
| .expect("ES15 stats should exist"); | ||
| let es16 = stats | ||
| .get(SpecEdition::ES16) | ||
| .expect("ES16 stats should exist"); | ||
|
|
||
| assert_eq!(es16.total, es15.total); | ||
| assert_eq!(es16.passed, es15.passed); | ||
| assert_eq!(es16.ignored, es15.ignored); | ||
| assert_eq!(es16.panic, es15.panic); | ||
| } | ||
|
|
||
| #[test] | ||
| fn apply_updates_es16_statistics() { | ||
|
||
| let mut stats = VersionedStats::default(); | ||
|
|
||
| stats.apply(SpecEdition::ES16, mark_passed); | ||
|
|
||
| let es15 = stats | ||
| .get(SpecEdition::ES15) | ||
| .expect("ES15 stats should exist"); | ||
| let es16 = stats | ||
| .get(SpecEdition::ES16) | ||
| .expect("ES16 stats should exist"); | ||
|
|
||
| assert_eq!(es15.total, 0); | ||
| assert_eq!(es15.passed, 0); | ||
| assert_eq!(es16.total, 1); | ||
| assert_eq!(es16.passed, 1); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need tests for these. Not because tests are bad or anything, but because the editions mapping is so in-flight sometimes that it's not really useful to test if specific features map to a certain version.
Case in point, if we had tests for these, then you wouldn't have been able to change the edition of these two features without changing the tests.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I removed those mapping tests in 50e871f. You’re right that pinning exact feature editions there would just create churn.