Merge branch 'master' of https://github.com/connorskees/grass
This commit is contained in:
commit
ccf33d2cfb
91
.github/workflows/tests.yml
vendored
Normal file
91
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: version info
|
||||
run: rustc --version; cargo --version;
|
||||
|
||||
- name: Run all tests
|
||||
run: cargo test
|
||||
|
||||
fmt:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
||||
|
||||
sass-spec:
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: version info
|
||||
run: rustc --version; cargo --version;
|
||||
|
||||
- name: Build binary
|
||||
run: cargo b --release
|
||||
|
||||
- name: Get sass-spec
|
||||
run: git submodule init && git submodule update
|
||||
|
||||
- name: Install whatever Ruby needs
|
||||
run: |
|
||||
sudo apt-get install libncurses5-dev libncursesw5-dev
|
||||
sudo gem install bundler
|
||||
cd sass-spec && bundler install
|
||||
|
||||
- name: Run Sass spec
|
||||
run: ./sass-spec/sass-spec.rb -c './target/release/grass'
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@
|
||||
Cargo.lock
|
||||
coverage
|
||||
pkg
|
||||
.idea/
|
||||
!input.scss
|
3
input.scss
Normal file
3
input.scss
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
background: red;
|
||||
}
|
@ -5,7 +5,6 @@ use codemap::{Span, Spanned};
|
||||
|
||||
use peekmore::PeekMoreIterator;
|
||||
|
||||
use crate::Cow;
|
||||
use crate::common::Identifier;
|
||||
use crate::error::SassResult;
|
||||
use crate::scope::Scope;
|
||||
@ -15,6 +14,7 @@ use crate::utils::{
|
||||
read_until_closing_paren, read_until_closing_quote, read_until_closing_square_brace,
|
||||
};
|
||||
use crate::value::Value;
|
||||
use crate::Cow;
|
||||
use crate::Token;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
@ -64,9 +64,7 @@ impl Media {
|
||||
}
|
||||
}
|
||||
|
||||
if super_selector.is_empty() {
|
||||
body.append(&mut rules);
|
||||
} else {
|
||||
if !super_selector.is_empty() {
|
||||
body = vec![Spanned {
|
||||
node: Stmt::RuleSet(RuleSet {
|
||||
selector: super_selector.clone(),
|
||||
@ -75,8 +73,8 @@ impl Media {
|
||||
}),
|
||||
span: kind_span,
|
||||
}];
|
||||
body.append(&mut rules);
|
||||
}
|
||||
body.append(&mut rules);
|
||||
|
||||
Ok(Media {
|
||||
super_selector: Selector::new(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::iter::Iterator;
|
||||
use std::borrow::Borrow;
|
||||
use std::iter::Iterator;
|
||||
|
||||
use codemap::{Span, Spanned};
|
||||
|
||||
|
@ -324,7 +324,9 @@ impl Value {
|
||||
format!("{}{}", self.to_css_string(span)?, s),
|
||||
QuoteKind::Quoted,
|
||||
),
|
||||
Self::Null => Value::String(self.to_css_string(span)?.into_owned(), QuoteKind::None),
|
||||
Self::Null => {
|
||||
Value::String(self.to_css_string(span)?.into_owned(), QuoteKind::None)
|
||||
}
|
||||
_ => Value::String(
|
||||
format!(
|
||||
"{}{}",
|
||||
|
@ -431,6 +431,12 @@ fn single_value<I: Iterator<Item = Token>>(
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_i64(s: String) -> i64 {
|
||||
s.as_bytes()
|
||||
.iter()
|
||||
.fold(0, |total, this| total * 10 + i64::from(this - b'0'))
|
||||
}
|
||||
|
||||
impl Value {
|
||||
pub fn from_tokens<I: Iterator<Item = Token>>(
|
||||
toks: &mut PeekMoreIterator<I>,
|
||||
@ -735,7 +741,7 @@ impl Value {
|
||||
|
||||
let n = if val.dec_len == 0 {
|
||||
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
||||
let n = Rational64::new_raw(val.num.parse::<i64>().unwrap(), 1);
|
||||
let n = Rational64::new_raw(parse_i64(val.num), 1);
|
||||
return Some(Ok(IntermediateValue::Value(Value::Dimension(
|
||||
Number::new_machine(n),
|
||||
unit,
|
||||
@ -745,8 +751,7 @@ impl Value {
|
||||
BigRational::new_raw(val.num.parse::<BigInt>().unwrap(), BigInt::one())
|
||||
} else {
|
||||
if val.num.len() <= 18 && val.times_ten.is_empty() {
|
||||
let n =
|
||||
Rational64::new(val.num.parse::<i64>().unwrap(), pow(10, val.dec_len));
|
||||
let n = Rational64::new(parse_i64(val.num), pow(10, val.dec_len));
|
||||
return Some(Ok(IntermediateValue::Value(Value::Dimension(
|
||||
Number::new_machine(n),
|
||||
unit,
|
||||
|
Loading…
x
Reference in New Issue
Block a user