<commit_before>namespace AngleSharp.Core.Tests.Css
{
    using AngleSharp.Dom.Css;
    using AngleSharp.Parser.Css;
    using NUnit.Framework;
    using System;

	[TestFixture]
	public class CssCasesTests : CssConstructionFunctions
	{
        static ICssStyleSheet ParseSheet(String text)
        {
            return ParseStyleSheet(text, new CssParserOptions
            {
                IsIncludingUnknownDeclarations = true,
                IsIncludingUnknownRules = true,
                IsToleratingInvalidConstraints = true,
                IsToleratingInvalidValues = true,
                IsToleratingInvalidSelectors = true
            });
        }

		[Test]
        public void StyleSheetAtNamespace()
		{
			var sheet = ParseSheet(@"@namespace svg ""http://www.w3.org/2000/svg"";");
			Assert.AreEqual(1, sheet.Rules.Length);
		}

		[Test]
        public void StyleSheetCharsetLinebreak()
		{
			var sheet = ParseSheet(@"@charset
    ""UTF-8""
    ;");
			Assert.AreEqual(1, sheet.Rules.Length);

			foreach (var rule in sheet.Rules)
				Assert.AreEqual(@"UTF-8", ((ICssCharsetRule)rule).CharacterSet);
		}

		[Test]
        public void StyleSheetCharset()
		{
			var sheet = ParseSheet(@"@charset ""UTF-8"";       /* Set the encoding of the style sheet to Unicode UTF-8 */
@charset 'iso-8859-15'; /* Set the encoding of the style sheet to Latin-9 (Western European languages, with euro sign) */
");
			Assert.AreEqual(2, sheet.Rules.Length);
            Assert.AreEqual(@"UTF-8", ((ICssCharsetRule)sheet.Rules[0]).CharacterSet);
            Assert.AreEqual(@"iso-8859-15", ((ICssCharsetRule)sheet.Rules[1]).CharacterSet);
		}

		[Test]
        public void StyleSheetColonSpace()
		{
			var sheet = ParseSheet(@"a {
    margin  : auto;
    padding : 0;
}");
			Assert.AreEqual(1, sheet.Rules.Length);

			foreach (var rule in sheet.Rules)
			{
				Assert.AreEqual(@"a", ((ICssStyleRule)rule).SelectorText);
				Assert.AreEqual(@"auto", ((ICssStyleRule)rule).Style["margin"]);
				Assert.AreEqual(@"0", ((ICssStyleRule)rule).Style["padding"]);
			}
		}

		[Test]
        public void StyleSheetCommaAttribute()
		{
			var sheet = ParseSheet(@".foo[bar=""baz,quz""] {
  foobar: 123;
}

.bar,
#bar[baz=""qux,foo""],
#qux {
  foobar: 456;
}

.baz[qux="",foo""],
.baz[qux=""foo,""],
.baz[qux=""foo,bar,baz""],
.baz[qux="",foo,bar,baz,""],
.baz[qux="" , foo , bar , baz , ""] {
  foobar: 789;
}

.qux[foo='bar,baz'],
.qux[bar=""baz,foo""],
#qux[foo=""foobar""],
#qux[foo=',bar,baz, '] {
  foobar: 012;
}

#foo[foo=""""],
#foo[bar="" ""],
#foo[bar="",""],
#foo[bar="", ""],
#foo[bar="" ,""],
#foo[bar="" , ""],
#foo[baz=''],
#foo[qux=' '],
#foo[qux=','],
#foo[qux=', '],
#foo[qux=' ,'],
#foo[qux=' , '] {
  foobar: 345;
}");
			Assert.AreEqual(5, sheet.Rules.Length);

            Assert.AreEqual(@".foo[bar=""baz,quz""]", ((ICssStyleRule)sheet.Rules[0]).SelectorText);
            Assert.AreEqual(@"123", ((ICssStyleRule)sheet.Rules[0]).Style["foobar"]);

            Assert.AreEqual(@".bar,#bar[baz=""qux,foo""],#qux", ((ICssStyleRule)sheet.Rules[1]).SelectorText);
            Assert.AreEqual(@"456", ((ICssStyleRule)sheet.Rules[1]).Style["foobar"]);

            Assert.AreEqual(@".baz[qux="",foo""],.baz[qux=""foo,""],.baz[qux=""foo,bar,baz""],.baz[qux="",foo,bar,baz,""],.baz[qux="" , foo , bar , baz , ""]", ((ICssStyleRule)sheet.Rules[2]).SelectorText);
            Assert.AreEqual(@"789", ((ICssStyleRule)sheet.Rules[2]).Style["foobar"]);

            Assert.AreEqual(@".qux[foo=""bar,baz""],.qux[bar=""baz,foo""],#qux[foo=""foobar""],#qux[foo="",bar,baz, ""]", ((ICssStyleRule)sheet.Rules[3]).SelectorText);
            Assert.AreEqual(@"012", ((ICssStyleRule)sheet.Rules[3]).Style["foobar"]);

            Assert.AreEqual(@"#foo[foo=""""],#foo[bar="" ""],#foo[bar="",""],#foo[bar="", ""],#foo[bar="" ,""],#foo[bar="" , ""],#foo[baz=""""],#foo[qux="" ""],#foo[qux="",""],#foo[qux="", ""],#foo[qux="" ,""],#foo[qux="" , ""]", ((ICssStyleRule)sheet.Rules[4]).SelectorText);
            Assert.AreEqual(@"345", ((ICssStyleRule)sheet.Rules[4]).Style["foobar"]);
		}

		[Test]
        public void StyleSheetCommaSelectorFunction()
		{
			var sheet = ParseSheet(@".foo:matches(.bar,.baz),
.foo:matches(.bar, .baz),
.foo:matches(.bar , .baz),
.foo:matches(.bar ,.baz) {
  prop: value;
}

.foo:matches(.bar,.baz,.foobar),
.foo:matches(.bar, .baz,),
.foo:matches(,.bar , .baz) {
  anotherprop: anothervalue;
}");
            Assert.AreEqual(2, sheet.Rules.Length);

            Assert.AreEqual(@".foo:matches(.bar,.baz),.foo:matches(.bar,.baz),.foo:matches(.bar,.baz),.foo:matches(.bar,.baz)", ((ICssStyleRule)sheet.Rules[0]).SelectorText);
            Assert.AreEqual(@"value", ((ICssStyleRule)sheet.Rules[0]).Style["prop"]);

            Assert.AreEqual(".foo:matches(.bar,.baz,.foobar),\n.foo:matches(.bar, .baz,),\n.foo:matches(,.bar , .baz) ", ((ICssStyleRule)sheet.Rules[1]).SelectorText);
            Assert.AreEqual(@"anothervalue", ((ICssStyleRule)sheet.Rules[1]).Style["anotherprop"]);
		}

		[Test]
        public void StyleSheetCommentIn()
		{
			var sheet = ParseSheet(@"a {
    color/**/: 12px;
    padding/*4815162342*/: 1px /**/ 2px /*13*/ 3px;
    border/*\**/: solid; border-top/*\**/: none\9;
}");
			Assert.AreEqual(1, sheet.Rules.Length);
            var rule = sheet.Rules[0];

            Assert.AreEqual(@"a", ((ICssStyleRule)rule).SelectorText);
            Assert.AreEqual(@"12px", ((ICssStyleRule)rule).Style["color"]);
            Assert.AreEqual(@"1px 2px 3px", ((ICssStyleRule)rule).Style["padding"]);
            Assert.AreEqual(@"solid", ((ICssStyleRule)rule).Style["border"]);
            Assert.AreEqual("none\t", ((ICssStyleRule)rule).Style["border-top"]);
		}

		[Test]
        public void StyleSheetCommentUrl()<commit_msg>In the literal source carriage return may appear<commit_after>namespace AngleSharp.Core.Tests.Css
{
    using AngleSharp.Dom.Css;
    using AngleSharp.Parser.Css;
    using NUnit.Framework;
    using System;

	[TestFixture]
	public class CssCasesTests : CssConstructionFunctions
	{
        static ICssStyleSheet ParseSheet(String text)
        {
            return ParseStyleSheet(text, new CssParserOptions
            {
                IsIncludingUnknownDeclarations = true,
                IsIncludingUnknownRules = true,
                IsToleratingInvalidConstraints = true,
                IsToleratingInvalidValues = true,
                IsToleratingInvalidSelectors = true
            });
        }

		[Test]
        public void StyleSheetAtNamespace()
		{
			var sheet = ParseSheet(@"@namespace svg ""http://www.w3.org/2000/svg"";");
			Assert.AreEqual(1, sheet.Rules.Length);
		}

		[Test]
        public void StyleSheetCharsetLinebreak()
		{
			var sheet = ParseSheet(@"@charset
    ""UTF-8""
    ;");
			Assert.AreEqual(1, sheet.Rules.Length);

			foreach (var rule in sheet.Rules)
				Assert.AreEqual(@"UTF-8", ((ICssCharsetRule)rule).CharacterSet);
		}

		[Test]
        public void StyleSheetCharset()
		{
			var sheet = ParseSheet(@"@charset ""UTF-8"";       /* Set the encoding of the style sheet to Unicode UTF-8 */
@charset 'iso-8859-15'; /* Set the encoding of the style sheet to Latin-9 (Western European languages, with euro sign) */
");
			Assert.AreEqual(2, sheet.Rules.Length);
            Assert.AreEqual(@"UTF-8", ((ICssCharsetRule)sheet.Rules[0]).CharacterSet);
            Assert.AreEqual(@"iso-8859-15", ((ICssCharsetRule)sheet.Rules[1]).CharacterSet);
		}

		[Test]
        public void StyleSheetColonSpace()
		{
			var sheet = ParseSheet(@"a {
    margin  : auto;
    padding : 0;
}");
			Assert.AreEqual(1, sheet.Rules.Length);

			foreach (var rule in sheet.Rules)
			{
				Assert.AreEqual(@"a", ((ICssStyleRule)rule).SelectorText);
				Assert.AreEqual(@"auto", ((ICssStyleRule)rule).Style["margin"]);
				Assert.AreEqual(@"0", ((ICssStyleRule)rule).Style["padding"]);
			}
		}

		[Test]
        public void StyleSheetCommaAttribute()
		{
			var sheet = ParseSheet(@".foo[bar=""baz,quz""] {
  foobar: 123;
}

.bar,
#bar[baz=""qux,foo""],
#qux {
  foobar: 456;
}

.baz[qux="",foo""],
.baz[qux=""foo,""],
.baz[qux=""foo,bar,baz""],
.baz[qux="",foo,bar,baz,""],
.baz[qux="" , foo , bar , baz , ""] {
  foobar: 789;
}

.qux[foo='bar,baz'],
.qux[bar=""baz,foo""],
#qux[foo=""foobar""],
#qux[foo=',bar,baz, '] {
  foobar: 012;
}

#foo[foo=""""],
#foo[bar="" ""],
#foo[bar="",""],
#foo[bar="", ""],
#foo[bar="" ,""],
#foo[bar="" , ""],
#foo[baz=''],
#foo[qux=' '],
#foo[qux=','],
#foo[qux=', '],
#foo[qux=' ,'],
#foo[qux=' , '] {
  foobar: 345;
}");
			Assert.AreEqual(5, sheet.Rules.Length);

            Assert.AreEqual(@".foo[bar=""baz,quz""]", ((ICssStyleRule)sheet.Rules[0]).SelectorText);
            Assert.AreEqual(@"123", ((ICssStyleRule)sheet.Rules[0]).Style["foobar"]);

            Assert.AreEqual(@".bar,#bar[baz=""qux,foo""],#qux", ((ICssStyleRule)sheet.Rules[1]).SelectorText);
            Assert.AreEqual(@"456", ((ICssStyleRule)sheet.Rules[1]).Style["foobar"]);

            Assert.AreEqual(@".baz[qux="",foo""],.baz[qux=""foo,""],.baz[qux=""foo,bar,baz""],.baz[qux="",foo,bar,baz,""],.baz[qux="" , foo , bar , baz , ""]", ((ICssStyleRule)sheet.Rules[2]).SelectorText);
            Assert.AreEqual(@"789", ((ICssStyleRule)sheet.Rules[2]).Style["foobar"]);

            Assert.AreEqual(@".qux[foo=""bar,baz""],.qux[bar=""baz,foo""],#qux[foo=""foobar""],#qux[foo="",bar,baz, ""]", ((ICssStyleRule)sheet.Rules[3]).SelectorText);
            Assert.AreEqual(@"012", ((ICssStyleRule)sheet.Rules[3]).Style["foobar"]);

            Assert.AreEqual(@"#foo[foo=""""],#foo[bar="" ""],#foo[bar="",""],#foo[bar="", ""],#foo[bar="" ,""],#foo[bar="" , ""],#foo[baz=""""],#foo[qux="" ""],#foo[qux="",""],#foo[qux="", ""],#foo[qux="" ,""],#foo[qux="" , ""]", ((ICssStyleRule)sheet.Rules[4]).SelectorText);
            Assert.AreEqual(@"345", ((ICssStyleRule)sheet.Rules[4]).Style["foobar"]);
		}

		[Test]
        public void StyleSheetCommaSelectorFunction()
		{
			var sheet = ParseSheet(@".foo:matches(.bar,.baz),
.foo:matches(.bar, .baz),
.foo:matches(.bar , .baz),
.foo:matches(.bar ,.baz) {
  prop: value;
}

.foo:matches(.bar,.baz,.foobar),
.foo:matches(.bar, .baz,),
.foo:matches(,.bar , .baz) {
  anotherprop: anothervalue;
}");
            Assert.AreEqual(2, sheet.Rules.Length);

            Assert.AreEqual(@".foo:matches(.bar,.baz),.foo:matches(.bar,.baz),.foo:matches(.bar,.baz),.foo:matches(.bar,.baz)", ((ICssStyleRule)sheet.Rules[0]).SelectorText);
            Assert.AreEqual(@"value", ((ICssStyleRule)sheet.Rules[0]).Style["prop"]);

            Assert.AreEqual(".foo:matches(.bar,.baz,.foobar),\r\n.foo:matches(.bar, .baz,),\r\n.foo:matches(,.bar , .baz) ", ((ICssStyleRule)sheet.Rules[1]).SelectorText);
            Assert.AreEqual(@"anothervalue", ((ICssStyleRule)sheet.Rules[1]).Style["anotherprop"]);
		}

		[Test]
        public void StyleSheetCommentIn()
		{
			var sheet = ParseSheet(@"a {
    color/**/: 12px;
    padding/*4815162342*/: 1px /**/ 2px /*13*/ 3px;
    border/*\**/: solid; border-top/*\**/: none\9;
}");
			Assert.AreEqual(1, sheet.Rules.Length);
            var rule = sheet.Rules[0];

            Assert.AreEqual(@"a", ((ICssStyleRule)rule).SelectorText);
            Assert.AreEqual(@"12px", ((ICssStyleRule)rule).Style["color"]);
            Assert.AreEqual(@"1px 2px 3px", ((ICssStyleRule)rule).Style["padding"]);
            Assert.AreEqual(@"solid", ((ICssStyleRule)rule).Style["border"]);
            Assert.AreEqual("none\t", ((ICssStyleRule)rule).Style["border-top"]);
		}

		[Test]
        public void StyleSheetCommentUrl()
{'fraction_non_alphanumeric': 0.22708027304933898, 'fraction_numerical': 0.017627235807482933, 'mean_word_length': 3.6148325358851676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4609546', 'n_tokens_mistral': 4548, 'n_tokens_neox': 4041, 'n_words': 556}