mirror of
https://github.com/servo/servo.git
synced 2025-08-13 09:25:32 +01:00
style: Fix / remove unit tests.
Unit tests removed have WPT equivalents.
This commit is contained in:
parent
26720e10a9
commit
fc4998367b
11 changed files with 58 additions and 162 deletions
|
@ -1,49 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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, ParserInput};
|
||||
use parsing::parse;
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::{Parse, ParserContext};
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::specified::length::{AbsoluteLength, Length, NoCalcLength};
|
||||
use style_traits::{ParsingMode, ToCss};
|
||||
|
||||
#[test]
|
||||
fn test_calc() {
|
||||
assert!(parse(Length::parse, "calc(1px+ 2px)").is_err());
|
||||
assert!(parse(Length::parse, "calc(calc(1px) + calc(1px + 4px))").is_ok());
|
||||
assert!(parse(Length::parse, "calc( 1px + 2px )").is_ok());
|
||||
assert!(parse(Length::parse, "calc(1px + 2px )").is_ok());
|
||||
assert!(parse(Length::parse, "calc( 1px + 2px)").is_ok());
|
||||
assert!(parse(Length::parse, "calc( 1px + 2px / ( 1 + 2 - 1))").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_length_literals() {
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33px", "0.33px");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33in", "0.33in");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33cm", "0.33cm");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33mm", "0.33mm");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33q", "0.33q");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33pt", "0.33pt");
|
||||
assert_roundtrip_with_context!(Length::parse, "0.33pc", "0.33pc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parsing_modes() {
|
||||
// In default length mode, non-zero lengths must have a unit.
|
||||
assert!(parse(Length::parse, "1").is_err());
|
||||
|
||||
// In SVG length mode, non-zero lengths are assumed to be px.
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let context = ParserContext::new(Origin::Author, &url,
|
||||
Some(CssRuleType::Style), ParsingMode::ALLOW_UNITLESS_LENGTH,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut input = ParserInput::new("1");
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let result = Length::parse(&context, &mut parser);
|
||||
assert!(result.is_ok());
|
||||
assert_eq!(result.unwrap(), Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(1.))));
|
||||
}
|
|
@ -21,7 +21,7 @@ where F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>> {
|
|||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let context = ParserContext::new(Origin::Author, &url, Some(CssRuleType::Style),
|
||||
ParsingMode::DEFAULT,
|
||||
QuirksMode::NoQuirks);
|
||||
QuirksMode::NoQuirks, None);
|
||||
let mut parser = Parser::new(input);
|
||||
f(&context, &mut parser)
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ mod column;
|
|||
mod effects;
|
||||
mod image;
|
||||
mod inherited_text;
|
||||
mod length;
|
||||
mod outline;
|
||||
mod position;
|
||||
mod selectors;
|
||||
|
@ -119,4 +118,3 @@ mod supports;
|
|||
mod text_overflow;
|
||||
mod transition_duration;
|
||||
mod transition_timing_function;
|
||||
mod value;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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, ParserInput};
|
||||
use style::context::QuirksMode;
|
||||
use style::parser::ParserContext;
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style::values::specified::Number;
|
||||
use style_traits::ParsingMode;
|
||||
|
||||
#[test]
|
||||
fn test_parsing_allo_all_numeric_values() {
|
||||
// In SVG length mode, non-zero lengths are assumed to be px.
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
let context = ParserContext::new(Origin::Author, &url,
|
||||
Some(CssRuleType::Style), ParsingMode::ALLOW_ALL_NUMERIC_VALUES,
|
||||
QuirksMode::NoQuirks);
|
||||
let mut input = ParserInput::new("-1");
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let result = Number::parse_non_negative(&context, &mut parser);
|
||||
assert!(result.is_ok());
|
||||
assert_eq!(result.unwrap(), Number::new(-1.));
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue