<commit_before>package css

import (
	"fmt"
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestMultipleSelectors(t *testing.T) {
	css := Parse(`div .a {
						font-size: 150%;
					}
					p .b {
						font-size: 250%;
					}`)

	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "div .a")
	assert.Equal(t, css.CssRuleList[1].Style.SelectorText, "p .b")

}

func TestIdSelector(t *testing.T) {
	css := Parse("#div { color: red;}")

	assert.Equal(t, css.CssRuleList[0].Style.Styles["color"].Value, "red")
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "#div")
}

func TestClassSelector(t *testing.T) {
	css := Parse(".div { color: green;}")

	assert.Equal(t, css.CssRuleList[0].Style.Styles["color"].Value, "green")
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, ".div")
}

func TestStarSelector(t *testing.T) {
	css := Parse("* { text-rendering: optimizelegibility; }")

	assert.Equal(t, "optimizelegibility", css.CssRuleList[0].Style.Styles["text-rendering"].Value)
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "*")
}

func TestStarSelectorMulti(t *testing.T) {
	css := Parse(`div .a {
						font-size: 150%;
					}
				* { text-rendering: optimizelegibility; }`)

	assert.Equal(t, "150%", css.CssRuleList[0].Style.Styles["font-size"].Value)
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "div .a")

	assert.Equal(t, "optimizelegibility", css.CssRuleList[1].Style.Styles["text-rendering"].Value)
	assert.Equal(t, css.CssRuleList[1].Style.SelectorText, "*")
}

func TestMixedClassSelectors(t *testing.T) {
	selectors := []string{".footer__content_wrapper--last",
							"table[class=\"body\"] .footer__content td",
							"table[class=\"body\"] td.footer__link_wrapper--first",
							"table[class=\"body\"] td.footer__link_wrapper--last"}
	
	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}

func TestGenericSelectors(t *testing.T) {
	selectors := []string{".header + .content",
							"p ~ ul",
							"div > p",
							"div > p",
							"div p",
							"div, p",
							"[target]",
							"[target=_blank]",
							"[title~=flower]",
							"[lang|=en]",
							"a[href^=\"https\"]",
							"a[href$=\".pdf\"]",
							"a[href*=\"css\"]"}
	
	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}


func TestFilterSelectors(t *testing.T) {
	selectors := []string{"a:active",
							"p::after",
							"p::before",
							"input:checked",
							"input:disabled",
							"p:empty",
							"input:enabled",
							"p:first-child",
							"p::first-letter",
							"p::first-line",
							"p:first-of-type",
							"input:focus",
							"a:hover",
							"input:in-range",
							"input:invalid",
							"p:lang(it)",
							"p:last-child",
							"p:last-of-type",
							"a:link",
							":not(p)",
							"p:nth-child(2)",
							"p:nth-last-child(2)",
							":root",
							"::selection",
							"#news:target"}
	
	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}

<commit_msg>Adding more selector cases<commit_after>package css

import (
	"fmt"
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestMultipleSelectors(t *testing.T) {
	css := Parse(`div .a {
						font-size: 150%;
					}
					p .b {
						font-size: 250%;
					}`)

	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "div .a")
	assert.Equal(t, css.CssRuleList[1].Style.SelectorText, "p .b")

}

func TestIdSelector(t *testing.T) {
	css := Parse("#div { color: red;}")

	assert.Equal(t, css.CssRuleList[0].Style.Styles["color"].Value, "red")
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "#div")
}

func TestClassSelector(t *testing.T) {
	css := Parse(".div { color: green;}")

	assert.Equal(t, css.CssRuleList[0].Style.Styles["color"].Value, "green")
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, ".div")
}

func TestStarSelector(t *testing.T) {
	css := Parse("* { text-rendering: optimizelegibility; }")

	assert.Equal(t, "optimizelegibility", css.CssRuleList[0].Style.Styles["text-rendering"].Value)
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "*")
}

func TestStarSelectorMulti(t *testing.T) {
	css := Parse(`div .a {
						font-size: 150%;
					}
				* { text-rendering: optimizelegibility; }`)

	assert.Equal(t, "150%", css.CssRuleList[0].Style.Styles["font-size"].Value)
	assert.Equal(t, css.CssRuleList[0].Style.SelectorText, "div .a")

	assert.Equal(t, "optimizelegibility", css.CssRuleList[1].Style.Styles["text-rendering"].Value)
	assert.Equal(t, css.CssRuleList[1].Style.SelectorText, "*")
}

func TestMixedClassSelectors(t *testing.T) {
	selectors := []string{".footer__content_wrapper--last",
		"table[class=\"body\"] .footer__content td",
		"table[class=\"body\"] td.footer__link_wrapper--first",
		"table[class=\"body\"] td.footer__link_wrapper--last"}

	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}

func TestGenericSelectors(t *testing.T) {
	selectors := []string{
		"p ~ ul",
		"div > p",
		"div > p",
		"div p",
		"div, p",
		"[target]",
		"[target=_blank]",
		"[title~=flower]",
		"[lang|=en]",
		"a[href^=\"https\"]",
		"a[href$=\".pdf\"]",
		"a[href*=\"css\"]",
		".header + .content",
		"#firstname",
		"table[class=\"body\"] .footer__content td",
		"table[class=\"body\"] td.footer__link_wrapper--first"}

	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}

func TestFilterSelectors(t *testing.T) {
	selectors := []string{
		"a:active",
		"p::after",
		"p::before",
		"input:checked",
		"input:disabled",
		"input:in-range",
		"input:invalid",
		"input:optional",
		"input:read-only",
		"input:enabled",
		"p:empty",
		"p:first-child",
		"p::first-letter",
		"p::first-line",
		"p:first-of-type",
		"input:focus",
		"a:hover",
		"p:lang(it)",
		"p:last-child",
		"p:last-of-type",
		"a:link",
		":not(p)",
		"p:nth-child(2)",
		"p:nth-last-child(2)",
		"p:only-of-type",
		"p:only-child",
		"p:nth-last-of-type(2)",
		"div:not(:nth-child(1))",
		"div:not(:not(:first-child))",
		":root",
		"::selection",
		"#news:target"}

	for _, selector := range selectors {
		css := Parse(fmt.Sprintf(` %s {
							    	border-collapse: separate;
							    	padding: 10px 0 0
							    	}`, selector))

		assert.Equal(t, "separate", css.CssRuleList[0].Style.Styles["border-collapse"].Value)
		assert.Equal(t, "10px 0 0", css.CssRuleList[0].Style.Styles["padding"].Value)
		assert.Equal(t, css.CssRuleList[0].Style.SelectorText, selector)
	}
}

{'fraction_non_alphanumeric': 0.20303067635826044, 'fraction_numerical': 0.014783787113465566, 'mean_word_length': 3.5453527435610304, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1169579', 'n_tokens_mistral': 3622, 'n_tokens_neox': 3033, 'n_words': 468}