/**
  * @covers ::from
  * @covers ::tokeniseExpression
  * @dataProvider provideInvalidVersionsToEvaluate
  * @expectedException GanbaroDigital\Versions\Exceptions\E4xx_BadVersionString
  */
 public function testRejectsBadVersions($expression)
 {
     // ----------------------------------------------------------------
     // setup your test
     $parser = new ParseSemanticVersion();
     // ----------------------------------------------------------------
     // perform the change
     ParseComparisonExpression::from($expression, $parser);
 }
 /**
  * turn one or more comparison strings into a VersionRangeList object
  *
  * e.g.
  *
  *     >= 1.0.0, <2.0, !1.5.9
  *     ~1.1
  *
  * @param  string $expression
  *         the string to parse
  * @param  VersionParser $parser
  *         the parser to use on the version numbers
  * @return VersionRange
  */
 public static function from($expression, VersionParser $parser)
 {
     // robustness!
     RequireStringy::check($expression, E4xx_UnsupportedType::class);
     // our final list
     $list = [];
     $parts = explode(",", (string) $expression);
     $parts = FilterOutEmptyValues::from($parts);
     foreach ($parts as $part) {
         $list[] = ParseComparisonExpression::from(trim($part), $parser);
     }
     return new VersionRange($list);
 }
 /**
  * @covers ::calculate
  * @dataProvider provideExpressionsToTest
  */
 public function testCanCallStatically($expression, $version, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     $parser = new ParseSemanticVersion();
     $expression = ParseComparisonExpression::from($expression, $parser);
     $version = $parser($version);
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = CompareExpression::calculate($expression, $version);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }