Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start implementing <font-weight-absolute> #62

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

koddsson
Copy link

Parking this here because I don't know what I'm doing 🫠

Comment on lines +39 to +43
atom!("normal") => Ok(Self::Normal(<T![Ident]>::build(p, c))),
atom!("bold") => Ok(Self::Bold(<T![Ident]>::build(p, c))),
atom!("bolder") => Ok(Self::Bolder(<T![Ident]>::build(p, c))),
atom!("lighter") => Ok(Self::Lighter(<T![Ident]>::build(p, c))),
atom => Err(diagnostics::UnexpectedIdent(atom, c.into()))?,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should have a Number => Ok(...) arm here as well but wasn't sure how to do that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’ll need something like

if p.peek::<T![Ident]>() {} else if p.peek::<T![Number]>() {}

Comment on lines +60 to +78
mod tests {
use super::*;
use crate::test_helpers::*;

#[test]
fn size_test() {
assert_size!(FontWeightAbsolute, 56);
}

#[test]
fn test_writes() {
assert_parse!(FontWeightAbsolute, "normal");
assert_parse!(FontWeightAbsolute, "bold");
assert_parse!(FontWeightAbsolute, "bolder");
assert_parse!(FontWeightAbsolute, "lighter");
assert_parse!(FontWeightAbsolute, "100");
assert_parse!(FontWeightAbsolute, "500");
assert_parse!(FontWeightAbsolute, "900");
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I run the tests for just this file in isolation so I can quickly get just warnings and errors that relate to this change? I'm a bit overwhelmed with all the output when I run cargo test :D

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo test -p hdx_ast scopes to just the hdx_astpackage, but you can also filter by module or test name so in the case runningcargo test -p hdx_ast css::values::fonts` should scope it to just these tests.

Copy link
Owner

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great so far!

Comment on lines +39 to +43
atom!("normal") => Ok(Self::Normal(<T![Ident]>::build(p, c))),
atom!("bold") => Ok(Self::Bold(<T![Ident]>::build(p, c))),
atom!("bolder") => Ok(Self::Bolder(<T![Ident]>::build(p, c))),
atom!("lighter") => Ok(Self::Lighter(<T![Ident]>::build(p, c))),
atom => Err(diagnostics::UnexpectedIdent(atom, c.into()))?,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’ll need something like

if p.peek::<T![Ident]>() {} else if p.peek::<T![Number]>() {}

Comment on lines +60 to +78
mod tests {
use super::*;
use crate::test_helpers::*;

#[test]
fn size_test() {
assert_size!(FontWeightAbsolute, 56);
}

#[test]
fn test_writes() {
assert_parse!(FontWeightAbsolute, "normal");
assert_parse!(FontWeightAbsolute, "bold");
assert_parse!(FontWeightAbsolute, "bolder");
assert_parse!(FontWeightAbsolute, "lighter");
assert_parse!(FontWeightAbsolute, "100");
assert_parse!(FontWeightAbsolute, "500");
assert_parse!(FontWeightAbsolute, "900");
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo test -p hdx_ast scopes to just the hdx_astpackage, but you can also filter by module or test name so in the case runningcargo test -p hdx_ast css::values::fonts` should scope it to just these tests.

use hdx_lexer::Cursor;
use hdx_parser::{diagnostics, Build, CursorStream, Parse, Parser, Peek, Result as ParserResult, ToCursors, T};

mod func {
Copy link
Owner

@keithamus keithamus Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, by convention, mod kw.

But I'd probably get rid of all the keywords and just peek an ident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants