mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Centralize ParserContext for tests
To simplify adding additional data to `ParserContext`, this moves test usages to a few shared locations, instead of being spread across many tests. MozReview-Commit-ID: 1OahV797eq
This commit is contained in:
parent
f7896fd80b
commit
0936dd24d0
27 changed files with 248 additions and 513 deletions
|
@ -2,13 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::Parser;
|
||||
use media_queries::CSSErrorReporterTest;
|
||||
use parsing::parse;
|
||||
use servo_url::ServoUrl;
|
||||
use style::parser::ParserContext;
|
||||
use style::properties::longhands::{self, perspective_origin, transform_origin};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[test]
|
||||
|
@ -37,48 +32,21 @@ fn test_clip() {
|
|||
|
||||
#[test]
|
||||
fn test_longhands_parse_origin() {
|
||||
let url = ServoUrl::parse("http://localhost").unwrap();
|
||||
let reporter = CSSErrorReporterTest;
|
||||
let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style));
|
||||
|
||||
let mut parser = Parser::new("1px some-rubbish");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), false);
|
||||
|
||||
let mut parser = Parser::new("1px 2px");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), true);
|
||||
|
||||
let mut parser = Parser::new("center left");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), true);
|
||||
|
||||
let mut parser = Parser::new("center right");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), true);
|
||||
|
||||
let mut parser = Parser::new("center right 1px");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), true);
|
||||
|
||||
let mut parser = Parser::new("1% right");
|
||||
let parsed = longhands::parse_origin(&context, &mut parser);
|
||||
assert!(parsed.is_ok());
|
||||
assert_eq!(parser.is_exhausted(), false);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "1px some-rubbish", false);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "1px 2px", true);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "center left", true);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "center right", true);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "center right 1px", true);
|
||||
assert_parser_exhausted!(longhands::parse_origin, "1% right", false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_effects_parser_exhaustion() {
|
||||
assert_parser_exhausted!(perspective_origin, "1px 1px", true);
|
||||
assert_parser_exhausted!(transform_origin, "1px 1px", true);
|
||||
assert_parser_exhausted!(perspective_origin::parse, "1px 1px", true);
|
||||
assert_parser_exhausted!(transform_origin::parse, "1px 1px", true);
|
||||
|
||||
assert_parser_exhausted!(perspective_origin, "1px some-rubbish", false);
|
||||
assert_parser_exhausted!(transform_origin, "1px some-rubbish", false);
|
||||
assert_parser_exhausted!(perspective_origin::parse, "1px some-rubbish", false);
|
||||
assert_parser_exhausted!(transform_origin::parse, "1px some-rubbish", false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue