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

Get tests passing on main #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 1 addition & 91 deletions src/html5_parser/parser/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,94 +108,4 @@ impl fmt::Display for Document {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.display_tree(self.get_root(), 0, f)
}
}

#[cfg(test)]
mod tests {
use crate::html5_parser::node::HTML_NAMESPACE;
use std::collections::HashMap;

#[test]
fn test_document() {
let mut document = super::Document::new();
let root_id = document.get_root().id;
let html_id = document.add_node(
super::Node::new_element("html", HashMap::new(), HTML_NAMESPACE),
root_id,
);
let head_id = document.add_node(
super::Node::new_element("head", HashMap::new(), HTML_NAMESPACE),
html_id,
);
let body_id = document.add_node(
super::Node::new_element("body", HashMap::new(), HTML_NAMESPACE),
html_id,
);
let title_id = document.add_node(
super::Node::new_element("title", HashMap::new(), HTML_NAMESPACE),
head_id,
);
let title_text_id = document.add_node(super::Node::new_text("Hello world"), title_id);
let p_id = document.add_node(
super::Node::new_element("p", HashMap::new(), HTML_NAMESPACE),
body_id,
);
let p_text_id = document.add_node(super::Node::new_text("This is a paragraph"), p_id);
let p_comment_id = document.add_node(super::Node::new_comment("This is a comment"), p_id);
let p_text2_id =
document.add_node(super::Node::new_text("This is another paragraph"), p_id);
let p_text3_id =
document.add_node(super::Node::new_text("This is a third paragraph"), p_id);
let p_text4_id =
document.add_node(super::Node::new_text("This is a fourth paragraph"), p_id);
let p_text5_id =
document.add_node(super::Node::new_text("This is a fifth paragraph"), p_id);
let p_text6_id =
document.add_node(super::Node::new_text("This is a sixth paragraph"), p_id);
let p_text7_id =
document.add_node(super::Node::new_text("This is a seventh paragraph"), p_id);
let p_text8_id =
document.add_node(super::Node::new_text("This is a eighth paragraph"), p_id);
let p_text9_id =
document.add_node(super::Node::new_text("This is a ninth paragraph"), p_id);

document.append(p_text9_id, p_id);
document.append(p_text8_id, p_id);
document.append(p_text7_id, p_id);
document.append(p_text6_id, p_id);
document.append(p_text5_id, p_id);
document.append(p_text4_id, p_id);
document.append(p_text3_id, p_id);
document.append(p_text2_id, p_id);
document.append(p_comment_id, p_id);
document.append(p_text_id, p_id);
document.append(p_id, body_id);
document.append(title_text_id, title_id);
document.append(title_id, head_id);
document.append(head_id, html_id);
document.append(body_id, html_id);
document.append(html_id, root_id);

assert_eq!(
format!("{}", document),
r#"Document
└─ <html>
└─ <head>
└─ <title>
└─ Hello world
└─ <body>
└─ <p>
└─ This is a paragraph
└─ <!-- This is a comment -->
└─ This is another paragraph
└─ This is a third paragraph
└─ This is a fourth paragraph
└─ This is a fifth paragraph
└─ This is a sixth paragraph
└─ This is a seventh paragraph
└─ This is a eighth paragraph
└─ This is a ninth paragraph
"#
);
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These tests would be reintroduced once they're all passing on a topic branch.

Copy link
Member

Choose a reason for hiding this comment

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

i agree.. I'm currently trying to fix those tests, but we can remove them for now. My goal is indeed a stable/compilable main branch

}
102 changes: 0 additions & 102 deletions src/html5_parser/tokenizer/character_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,106 +382,4 @@ mod tests {
)*
}
}

entity_tests! {
// Numbers
entity_0: ("&#10;", "\n")
entity_1: ("&#0;", "�")
entity_2: ("&#x0;", "�")
entity_3: ("&#xdeadbeef;", "�") // replace with replacement char
entity_4: ("&#xd888;", "�") // replace with replacement char
entity_5: ("&#xbeef;", "뻯")
entity_6: ("&#x10;", "�") // reserved codepoint
entity_7: ("&#;", "&#;")
entity_8: ("&;", "&;")
entity_9: ("&", "&")
entity_10: ("&#x1;", "�") // reserved codepoint
entity_11: ("&#x0008;", "�") // reserved codepoint
entity_12: ("&#0008;", "�") // reserved codepoint
entity_13: ("&#8;", "�") // reserved codepoint
entity_14: ("&#x0009;", "\t")
entity_15: ("&#x007F;", "�") // reserved codepoint
entity_16: ("&#xFDD0;", "�") // reserved codepoint

// Entities
entity_100: ("&copy;", "©")
entity_101: ("&copyThing;", "©Thing;")
entity_102: ("&raquo;", "»")
entity_103: ("&laquo;", "«")
entity_104: ("&not;", "¬")
entity_105: ("&notit;", "¬it;")
entity_106: ("&notin;", "∉")
entity_107: ("&fo", "&fo")
entity_108: ("&xxx", "&xxx")
entity_109: ("&copy", "©")
entity_110: ("&copy ", "© ")
entity_111: ("&copya", "©a")
entity_112: ("&copya;", "©a;")
entity_113: ("&#169;", "©")
// entity_114: ("&copy&", "©&")
entity_115: ("&copya ", "©a ")
entity_116: ("&#169X ", "©X ")


// ChatGPT generated tests
entity_200: ("&copy;", "©")
entity_201: ("&copy ", "© ")
entity_202: ("&#169;", "©")
entity_203: ("&#xA9;", "©")
entity_204: ("&lt;", "<")
entity_205: ("&unknown;", "&unknown;")
entity_206: ("&#60;", "<")
entity_207: ("&#x3C;", "<")
entity_208: ("&amp;", "&")
entity_209: ("&euro;", "€")
entity_210: ("&gt;", ">")
entity_211: ("&reg;", "®")
entity_212: ("&#174;", "®")
entity_213: ("&#xAE;", "®")
entity_214: ("&quot;", "\"")
entity_215: ("&#34;", "\"")
entity_216: ("&#x22;", "\"")
entity_217: ("&apos;", "'")
entity_218: ("&#39;", "'")
entity_219: ("&#x27;", "'")
entity_220: ("&excl;", "!")
entity_221: ("&#33;", "!")
entity_222: ("&num;", "#")
entity_223: ("&#35;", "#")
entity_224: ("&dollar;", "$")
entity_225: ("&#36;", "$")
entity_226: ("&percnt;", "%")
entity_227: ("&#37;", "%")
entity_228: ("&ast;", "*")
entity_229: ("&#42;", "*")
entity_230: ("&plus;", "+")
entity_231: ("&#43;", "+")
entity_232: ("&comma;", ",")
entity_233: ("&#44;", ",")
entity_234: ("&minus;", "−")
entity_235: ("&#45;", "-")
entity_236: ("&period;", ".")
entity_237: ("&#46;", ".")
entity_238: ("&sol;", "/")
entity_239: ("&#47;", "/")
entity_240: ("&colon;", ":")
entity_241: ("&#58;", ":")
entity_242: ("&semi;", ";")
entity_243: ("&#59;", ";")
entity_244: ("&equals;", "=")
entity_245: ("&#61;", "=")
entity_246: ("&quest;", "?")
entity_247: ("&#63;", "?")
entity_248: ("&commat;", "@")
entity_249: ("&#64;", "@")
entity_250: ("&COPY;", "©")
entity_251: ("&#128;", "€")
entity_252: ("&#x9F;", "Ÿ")
entity_253: ("&#31;", "")
entity_254: ("&#0;", "�")
entity_255: ("&#xD800;", "�")
entity_256: ("&unknownchar;", "&unknownchar;")
entity_257: ("&#9999999;", "�")
entity_259: ("&#11;", "")
}
}
Loading