-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ordering to Stable, Beta, Nightly
- Loading branch information
1 parent
b9ab5ad
commit 3413bdb
Showing
4 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::RustVersion; | ||
|
||
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] | ||
pub struct Beta { | ||
pub version: RustVersion, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::{Beta, RustVersion}; | ||
|
||
#[yare::parameterized( | ||
day1 = { RustVersion::new(0, 0, 0), RustVersion::new(0, 0, 1) }, | ||
month1 = { RustVersion::new(0, 0, 0), RustVersion::new(0, 1, 0) }, | ||
year1 = { RustVersion::new(0, 0, 0), RustVersion::new(1, 0, 0) }, | ||
month_trumps_day = { RustVersion::new(0, 0, 999), RustVersion::new(0, 1, 0) }, | ||
year_trumps_day = { RustVersion::new(0, 0, 999), RustVersion::new(1, 0, 0) }, | ||
year_trumps_month = { RustVersion::new(0, 999, 0), RustVersion::new(1, 0, 0) }, | ||
)] | ||
fn ord(left: RustVersion, right: RustVersion) { | ||
let left = Beta { version: left }; | ||
let right = Beta { version: right }; | ||
|
||
assert!(left < right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::ReleaseDate; | ||
|
||
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] | ||
pub struct Nightly { | ||
pub date: ReleaseDate, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::{Nightly, ReleaseDate}; | ||
|
||
#[yare::parameterized( | ||
patch1 = { ReleaseDate::new(0, 0, 0), ReleaseDate::new(0, 0, 1) }, | ||
minor1 = { ReleaseDate::new(0, 0, 0), ReleaseDate::new(0, 1, 0) }, | ||
major1 = { ReleaseDate::new(0, 0, 0), ReleaseDate::new(1, 0, 0) }, | ||
minor_trumps_patch = { ReleaseDate::new(0, 0, 99), ReleaseDate::new(0, 1, 0) }, | ||
major_trumps_patch = { ReleaseDate::new(0, 0, 99), ReleaseDate::new(1, 0, 0) }, | ||
major_trumps_minor = { ReleaseDate::new(0, 99, 0), ReleaseDate::new(1, 0, 0) }, | ||
)] | ||
fn ord(left: ReleaseDate, right: ReleaseDate) { | ||
let left = Nightly { date: left }; | ||
let right = Nightly { date: right }; | ||
|
||
assert!(left < right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::RustVersion; | ||
|
||
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] | ||
pub struct Stable { | ||
pub version: RustVersion, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::{RustVersion, Stable}; | ||
|
||
#[yare::parameterized( | ||
patch1 = { RustVersion::new(0, 0, 0), RustVersion::new(0, 0, 1) }, | ||
minor1 = { RustVersion::new(0, 0, 0), RustVersion::new(0, 1, 0) }, | ||
major1 = { RustVersion::new(0, 0, 0), RustVersion::new(1, 0, 0) }, | ||
minor_trumps_patch = { RustVersion::new(0, 0, 999), RustVersion::new(0, 1, 0) }, | ||
major_trumps_patch = { RustVersion::new(0, 0, 999), RustVersion::new(1, 0, 0) }, | ||
major_trumps_minor = { RustVersion::new(0, 999, 0), RustVersion::new(1, 0, 0) }, | ||
)] | ||
fn ord(left: RustVersion, right: RustVersion) { | ||
let left = Stable { version: left }; | ||
let right = Stable { version: right }; | ||
|
||
assert!(left < right); | ||
} | ||
} |