tamer: obj::xmlo::{air,reader}::test: Format test cases

Simple reformatting that's consistent with other more recent tests, before I
go making changes.

DEV-13162
main
Mike Gerwitz 2023-05-05 08:42:25 -04:00
parent 48bcb0cdab
commit 13bac8382f
3 changed files with 270 additions and 230 deletions

View File

@ -36,10 +36,11 @@ fn data_from_package_event() {
let name = "name".into();
let relroot = "some/path".into();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair(name, S2)),
PkgRootPath(SPair(relroot, S4)),
PkgName(SPair(name, S2)),
PkgRootPath(SPair(relroot, S4)),
Eoh(S4),
]
.into_iter();
@ -47,11 +48,12 @@ fn data_from_package_event() {
let mut sut = Sut::parse(toks);
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
Incomplete, // PkgRootPath
O(Air::PkgEnd(S4)), // Eoh
Incomplete, // PkgName
Incomplete, // PkgRootPath
O(Air::PkgEnd(S4)),
]),
sut.by_ref().collect(),
);
@ -67,18 +69,20 @@ fn adds_elig_as_root() {
let name = "name-root".into();
let elig_sym = "elig".into();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair(name, S2)),
PkgEligClassYields(SPair(elig_sym, S3)),
PkgName(SPair(name, S2)),
PkgEligClassYields(SPair(elig_sym, S3)),
Eoh(S4),
];
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
O(Air::IdentRoot(SPair(elig_sym, S3))),
Incomplete, // PkgName
O(Air::IdentRoot(SPair(elig_sym, S3))),
O(Air::PkgEnd(S4)), // Eoh
]),
Sut::parse(toks.into_iter()).collect(),
@ -91,22 +95,25 @@ fn adds_sym_deps() {
let sym_to1 = "to1".into();
let sym_to2 = "to2".into();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair("name".into(), S2)),
SymDepStart(SPair(sym_from, S3)),
Symbol(SPair(sym_to1, S4)),
Symbol(SPair(sym_to2, S5)),
PkgName(SPair("name".into(), S2)),
SymDepStart(SPair(sym_from, S3)),
Symbol(SPair(sym_to1, S4)),
Symbol(SPair(sym_to2, S5)),
Eoh(S6),
];
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
Incomplete, // SymDepStart
O(Air::IdentDep(SPair(sym_from, S3), SPair(sym_to1, S4))),
O(Air::IdentDep(SPair(sym_from, S3), SPair(sym_to2, S5))),
Incomplete, // PkgName
Incomplete, // SymDepStart
O(Air::IdentDep(SPair(sym_from, S3), SPair(sym_to1, S4))),
O(Air::IdentDep(SPair(sym_from, S3), SPair(sym_to2, S5))),
O(Air::PkgEnd(S6)),
]),
Sut::parse(toks.into_iter()).collect(),
@ -119,34 +126,37 @@ fn sym_decl_with_src_not_added_and_populates_found() {
let src_a = "src_a".into();
let src_b = "src_b".into();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair("name".into(), S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
src: Some(src_a),
..Default::default()
},
),
SymDecl(
SPair(sym, S4),
SymAttrs {
src: Some(src_b),
..Default::default()
},
),
PkgName(SPair("name".into(), S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
src: Some(src_a),
..Default::default()
},
),
SymDecl(
SPair(sym, S4),
SymAttrs {
src: Some(src_b),
..Default::default()
},
),
Eoh(S5),
];
let mut sut = Sut::parse(toks.into_iter());
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
Incomplete, // SymDecl (@src)
Incomplete, // SymDecl (@src)
Incomplete, // PkgName
Incomplete, // SymDecl (@src)
Incomplete, // SymDecl (@src)
O(Air::PkgEnd(S5)),
]),
sut.by_ref().collect(),
@ -170,42 +180,44 @@ fn sym_decl_added_to_graph() {
let sym_retmap = "sym_retmap".into();
let pkg_name = "pkg name".into();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair("name".into(), S2)),
SymDecl(
SPair(sym_extern, S3),
SymAttrs {
pkg_name: Some(pkg_name),
extern_: true,
ty: Some(SymType::Meta),
..Default::default()
},
),
SymDecl(
SPair(sym_non_extern, S4),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Meta),
..Default::default()
},
),
SymDecl(
SPair(sym_map, S5),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Map),
..Default::default()
},
),
SymDecl(
SPair(sym_retmap, S6),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::RetMap),
..Default::default()
},
),
PkgName(SPair("name".into(), S2)),
SymDecl(
SPair(sym_extern, S3),
SymAttrs {
pkg_name: Some(pkg_name),
extern_: true,
ty: Some(SymType::Meta),
..Default::default()
},
),
SymDecl(
SPair(sym_non_extern, S4),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Meta),
..Default::default()
},
),
SymDecl(
SPair(sym_map, S5),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Map),
..Default::default()
},
),
SymDecl(
SPair(sym_retmap, S6),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::RetMap),
..Default::default()
},
),
Eoh(S7),
];
@ -284,32 +296,36 @@ fn sym_decl_pkg_name_retained_if_not_first() {
..Default::default()
};
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair(pkg_name, S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Meta),
..Default::default()
},
),
PkgName(SPair(pkg_name, S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
pkg_name: Some(pkg_name),
ty: Some(SymType::Meta),
..Default::default()
},
),
Eoh(S4),
];
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
O(Air::IdentDecl(
SPair(sym, S3),
IdentKind::Meta,
Source {
pkg_name: Some(pkg_name),
..Default::default()
}
)),
Incomplete, // PkgName
O(Air::IdentDecl(
SPair(sym, S3),
IdentKind::Meta,
Source {
pkg_name: Some(pkg_name),
..Default::default()
}
)),
O(Air::PkgEnd(S4)),
]),
Sut::parse_with_context(toks.into_iter(), ctx).collect(),
@ -328,32 +344,36 @@ fn sym_decl_pkg_name_set_if_empty_and_not_first() {
..Default::default()
};
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair(pkg_name, S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
// No name
ty: Some(SymType::Meta),
..Default::default()
},
),
PkgName(SPair(pkg_name, S2)),
SymDecl(
SPair(sym, S3),
SymAttrs {
// No name
ty: Some(SymType::Meta),
..Default::default()
},
),
Eoh(S4),
];
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
O(Air::IdentDecl(
SPair(sym, S3),
IdentKind::Meta,
Source {
pkg_name: Some(pkg_name), // Name inherited
..Default::default()
},
)),
Incomplete, // PkgName
O(Air::IdentDecl(
SPair(sym, S3),
IdentKind::Meta,
Source {
pkg_name: Some(pkg_name), // Name inherited
..Default::default()
},
)),
O(Air::PkgEnd(S4)),
]),
Sut::parse_with_context(toks.into_iter(), ctx).collect(),
@ -365,10 +385,11 @@ fn ident_kind_conversion_error_propagates() {
let sym = "sym".into();
let bad_attrs = SymAttrs::default();
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair("name".into(), S2)),
SymDecl(SPair(sym, S3), bad_attrs),
PkgName(SPair("name".into(), S2)),
SymDecl(SPair(sym, S3), bad_attrs),
Eoh(S1),
];
@ -382,18 +403,20 @@ fn sets_fragment() {
let sym = "sym".into();
let frag = FragmentText::from("foo");
#[rustfmt::skip]
let toks = vec![
PkgStart(S1),
PkgName(SPair("name".into(), S2)),
Fragment(SPair(sym, S3), frag.clone()),
PkgName(SPair("name".into(), S2)),
Fragment(SPair(sym, S3), frag.clone()),
Eoh(S4),
];
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(Air::PkgStart(S1)),
Incomplete, // PkgName
O(Air::IdentFragment(SPair(sym, S3), frag)),
Incomplete, // PkgName
O(Air::IdentFragment(SPair(sym, S3), frag)),
O(Air::PkgEnd(S4)),
]),
Sut::parse(toks.into_iter()).collect(),

View File

@ -28,9 +28,8 @@ use crate::{
span::{dummy::*, Span},
sym::GlobalSymbolIntern,
xir::{
attr::Attr,
flat::{
test::{close, close_empty, open},
test::{attr, close, close_empty, open},
Depth, XirfToken as Xirf,
},
QName,
@ -59,20 +58,13 @@ fn common_parses_package_attrs(package: QName) {
let relroot = "../../".into();
let elig = "elig-class-yields".into();
#[rustfmt::skip]
let toks = [
open(package, S1, Depth(0)),
Xirf::Attr(Attr::new("name".unwrap_into(), name, (S2, S3))),
Xirf::Attr(Attr::new("__rootpath".unwrap_into(), relroot, (S2, S3))),
Xirf::Attr(Attr::new(
"program".unwrap_into(),
crate::sym::st::raw::L_TRUE,
(S3, S4),
)),
Xirf::Attr(Attr::new(
("preproc", "elig-class-yields").unwrap_into(),
elig,
(S3, S4),
)),
attr("name", name, (S2, S3)),
attr("__rootpath", relroot, (S2, S3)),
attr("program", crate::sym::st::raw::L_TRUE, (S3, S4)),
attr(("preproc", "elig-class-yields"), elig, (S3, S4)),
close(Some(package), S2, Depth(0)),
]
.into_iter();
@ -80,16 +72,17 @@ fn common_parses_package_attrs(package: QName) {
let sut = Sut::parse(toks);
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(PkgStart(S1)),
O(PkgName(SPair(name, S3))),
O(PkgRootPath(SPair(relroot, S3))),
// Span for the program flag is the attr name,
// rather than the value,
// since the value is just a boolean and does not provide as
// useful of context.
O(PkgProgramFlag(S3)),
O(PkgEligClassYields(SPair(elig, S4))),
O(PkgName(SPair(name, S3))),
O(PkgRootPath(SPair(relroot, S3))),
// Span for the program flag is the attr name,
// rather than the value,
// since the value is just a boolean and does not provide as
// useful of context.
O(PkgProgramFlag(S3)),
O(PkgEligClassYields(SPair(elig, S4))),
Incomplete,
]),
sut.collect(),
@ -114,11 +107,12 @@ fn parses_package_attrs_with_ns_prefix() {
fn ignores_unknown_package_attr() {
let name = "pkgroot".into();
#[rustfmt::skip]
let toks = [
open(QN_PACKAGE, S1, Depth(0)),
Xirf::Attr(Attr::new("name".unwrap_into(), name, (S2, S3))),
// This is ignored.
Xirf::Attr(Attr::new("unknown".unwrap_into(), name, (S2, S3))),
attr("name", name, (S2, S3)),
// This is ignored.
attr("unknown", name, (S2, S3)),
close(Some(QN_PACKAGE), S2, Depth(0)),
]
.into_iter();
@ -126,10 +120,11 @@ fn ignores_unknown_package_attr() {
let sut = Sut::parse(toks);
assert_eq!(
#[rustfmt::skip]
Ok(vec![
O(PkgStart(S1)),
O(PkgName(SPair(name, S3))),
Incomplete, // The unknown attribute
O(PkgName(SPair(name, S3))),
Incomplete, // The unknown attribute
Incomplete,
]),
sut.collect(),
@ -169,13 +164,13 @@ macro_rules! symtable_tests {
let toks = [
open(QN_P_SYM, SSYM, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
attr(QN_NAME, name, (S2, S3)),
$(
Xirf::Attr(Attr(
stringify!($key).unwrap_into(),
attr(
stringify!($key),
$val.unwrap_into(),
AttrSpan(S3, SATTRVAL)
)),
(S3, SATTRVAL)
),
)*
close(Some(QN_P_SYM), S2, Depth(0)),
]
@ -329,14 +324,15 @@ symtable_tests! {
fn symtable_sym_generated_true() {
let name = "generated_true".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM, SSYM, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
Xirf::Attr(Attr(
("preproc", "generated").unwrap_into(),
raw::L_TRUE,
AttrSpan(S3, S4),
)),
attr(QN_NAME, name, (S2, S3)),
attr(
("preproc", "generated"),
raw::L_TRUE,
(S3, S4),
),
close(Some(QN_P_SYM), S2, Depth(0)),
]
.into_iter();
@ -347,6 +343,7 @@ fn symtable_sym_generated_true() {
};
assert_eq!(
#[rustfmt::skip]
Ok(vec![
Incomplete, // Opening tag
Incomplete, // @name
@ -364,15 +361,17 @@ fn symtable_map_from() {
let name = "sym-map-from".into();
let map_from = "from-a".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM, SSYM, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
Xirf::Attr(Attr(QN_TYPE, raw::L_MAP, AttrSpan(S3, S4))),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
Xirf::Attr(Attr(QN_NAME, map_from, AttrSpan(S2, S3))),
close_empty(S4, Depth(1)),
// />
attr(QN_NAME, name, (S2, S3)),
attr(QN_TYPE, raw::L_MAP, (S3, S4)),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
attr(QN_NAME, map_from, (S2, S3)),
close_empty(S4, Depth(1)),
// />
close(Some(QN_P_SYM), S2, Depth(0)),
]
.into_iter();
@ -401,15 +400,17 @@ fn symtable_map_from() {
fn symtable_map_from_missing_name() {
let name = "sym-map-from-missing".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM, SSYM, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
Xirf::Attr(Attr(QN_TYPE, raw::L_MAP, AttrSpan(S3, S4))),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
// @name missing
close_empty(S4, Depth(1)),
// />
attr(QN_NAME, name, (S2, S3)),
attr(QN_TYPE, raw::L_MAP, (S3, S4)),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
// @name missing
close_empty(S4, Depth(1)),
// />
close(Some(QN_P_SYM), S2, Depth(0)),
]
.into_iter();
@ -426,20 +427,23 @@ fn symtable_map_from_missing_name() {
fn symtable_map_from_multiple() {
let name = "sym-map-from-missing".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM, SSYM, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
Xirf::Attr(Attr(QN_TYPE, raw::L_MAP, AttrSpan(S3, S4))),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
Xirf::Attr(Attr(QN_NAME, "ok".into(), AttrSpan(S2, S3))),
close_empty(S4, Depth(1)),
// />
// <preproc:from> again (err)
open(QN_P_FROM, S3, Depth(1)),
Xirf::Attr(Attr(QN_NAME, "bad".into(), AttrSpan(S2, S3))),
close_empty(S4, Depth(1)),
// />
attr(QN_NAME, name, (S2, S3)),
attr(QN_TYPE, raw::L_MAP, (S3, S4)),
// <preproc:from>
open(QN_P_FROM, S2, Depth(1)),
attr(QN_NAME, "ok".into(), (S2, S3)),
close_empty(S4, Depth(1)),
// />
// <preproc:from> again (err)
open(QN_P_FROM, S3, Depth(1)),
attr(QN_NAME, "bad".into(), (S2, S3)),
close_empty(S4, Depth(1)),
// />
close(Some(QN_P_SYM), S2, Depth(0)),
]
.into_iter();
@ -457,19 +461,22 @@ fn sym_dep_event() {
let dep1 = "dep1".into();
let dep2 = "dep2".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM_DEP, S1, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
// <preproc:sym-ref
open(QN_P_SYM_REF, S2, Depth(1)),
Xirf::Attr(Attr(QN_NAME, dep1, AttrSpan(S3, S4))),
close_empty(S4, Depth(1)),
// />
// <preproc:sym-ref
open(QN_P_SYM_REF, S3, Depth(1)),
Xirf::Attr(Attr(QN_NAME, dep2, AttrSpan(S4, S5))),
close_empty(S4, Depth(1)),
// />
attr(QN_NAME, name, (S2, S3)),
// <preproc:sym-ref
open(QN_P_SYM_REF, S2, Depth(1)),
attr(QN_NAME, dep1, (S3, S4)),
close_empty(S4, Depth(1)),
// />
// <preproc:sym-ref
open(QN_P_SYM_REF, S3, Depth(1)),
attr(QN_NAME, dep2, (S4, S5)),
close_empty(S4, Depth(1)),
// />
close(Some(QN_P_SYM_DEP), S5, Depth(0)),
]
.into_iter();
@ -510,12 +517,14 @@ fn sym_dep_missing_name() {
fn sym_ref_missing_name() {
let name = "depsym".into();
#[rustfmt::skip]
let toks = [
open(QN_P_SYM_DEP, S1, Depth(0)),
Xirf::Attr(Attr(QN_NAME, name, AttrSpan(S2, S3))),
open(QN_P_SYM_REF, S2, Depth(1)),
// missing @name, causes error
close_empty(S3, Depth(1)),
attr(QN_NAME, name, (S2, S3)),
open(QN_P_SYM_REF, S2, Depth(1)),
// missing @name, causes error
close_empty(S3, Depth(1)),
]
.into_iter();
@ -533,16 +542,18 @@ fn sym_fragment_event() {
let frag1 = "fragment text 1".into();
let frag2 = "fragment text 2".into();
#[rustfmt::skip]
let toks = [
// first
open(QN_P_FRAGMENT, S1, Depth(0)),
Xirf::Attr(Attr(QN_ID, id1, AttrSpan(S2, S3))),
Xirf::Text(Text(frag1, S4), Depth(1)),
attr(QN_ID, id1, (S2, S3)),
Xirf::Text(Text(frag1, S4), Depth(1)),
close(Some(QN_P_FRAGMENT), S5, Depth(0)),
// second
open(QN_P_FRAGMENT, S2, Depth(0)),
Xirf::Attr(Attr(QN_ID, id2, AttrSpan(S3, S4))),
Xirf::Text(Text(frag2, S5), Depth(1)),
attr(QN_ID, id2, (S3, S4)),
Xirf::Text(Text(frag2, S5), Depth(1)),
close(Some(QN_P_FRAGMENT), S5, Depth(0)),
]
.into_iter();
@ -584,7 +595,7 @@ fn sym_fragment_empty_id() {
let toks = [
open(QN_P_FRAGMENT, S1, Depth(0)),
// empty @id
Xirf::Attr(Attr(QN_ID, "".into(), AttrSpan(S3, S4))),
attr(QN_ID, "".into(), (S3, S4)),
Xirf::Text(Text("text".into(), S4), Depth(1)),
]
.into_iter();
@ -604,7 +615,7 @@ fn _sym_fragment_missing_text() {
let toks = [
open(QN_P_FRAGMENT, S1, Depth(0)),
Xirf::Attr(Attr(QN_ID, id, AttrSpan(S3, S4))),
attr(QN_ID, id, (S3, S4)),
// missing text
close(Some(QN_P_FRAGMENT), S5, Depth(0)),
]
@ -630,50 +641,42 @@ fn xmlo_composite_parsers_header() {
let symfrag_id = "symfrag".into();
let frag = "fragment text".into();
#[rustfmt::skip]
let toks_header = [
open(QN_PACKAGE, S1, Depth(0)),
// <preproc:symtable>
open(QN_P_SYMTABLE, S2, Depth(1)),
// <preproc:sym
open(QN_P_SYM, S3, Depth(2)),
Xirf::Attr(Attr(QN_NAME, sym_name, AttrSpan(S2, S3))),
close_empty(S4, Depth(2)),
// />
close(Some(QN_P_SYMTABLE), S4, Depth(1)),
// </preproc:symtable>
// <preproc:sym-deps>
open(QN_P_SYM_DEPS, S2, Depth(1)),
// <preproc:sym-dep
open(QN_P_SYM_DEP, S3, Depth(3)),
Xirf::Attr(Attr(QN_NAME, symdep_name, AttrSpan(S2, S3))),
close(Some(QN_P_SYM_DEP), S4, Depth(3)),
// </preproc:sym-dep>
close(Some(QN_P_SYM_DEPS), S3, Depth(1)),
// </preproc:sym-deps>
// <preproc:fragments>
open(QN_P_FRAGMENTS, S2, Depth(1)),
// <preproc:fragment
open(QN_P_FRAGMENT, S4, Depth(2)),
Xirf::Attr(Attr(QN_ID, symfrag_id, AttrSpan(S2, S3))),
Xirf::Text(Text(frag, S5), Depth(3)),
close(Some(QN_P_FRAGMENT), S4, Depth(2)),
// </preproc:fragment>
close(Some(QN_P_FRAGMENTS), S3, Depth(1)),
// </preproc:fragments>
// No closing root node:
// ensure that we can just end at the header without parsing further).
open(QN_P_SYMTABLE, S2, Depth(1)),
open(QN_P_SYM, S3, Depth(2)),
attr(QN_NAME, sym_name, (S2, S3)),
close_empty(S4, Depth(2)),
close(Some(QN_P_SYMTABLE), S4, Depth(1)),
open(QN_P_SYM_DEPS, S2, Depth(1)),
open(QN_P_SYM_DEP, S3, Depth(3)),
attr(QN_NAME, symdep_name, (S2, S3)),
close(Some(QN_P_SYM_DEP), S4, Depth(3)),
close(Some(QN_P_SYM_DEPS), S3, Depth(1)),
open(QN_P_FRAGMENTS, S2, Depth(1)),
open(QN_P_FRAGMENT, S4, Depth(2)),
attr(QN_ID, symfrag_id, (S2, S3)),
Xirf::Text(Text(frag, S5), Depth(3)),
close(Some(QN_P_FRAGMENT), S4, Depth(2)),
close(Some(QN_P_FRAGMENTS), S3, Depth(1)),
// No closing root node:
// ensure that we can just end at the header without parsing further).
]
.into_iter();
let sut = Sut::parse(toks_header);
#[rustfmt::skip]
assert_eq!(
Ok(vec![
O(PkgStart(S1)),
O(SymDecl(SPair(sym_name, S3), Default::default(),)),
O(SymDepStart(SPair(symdep_name, S3))),
O(Fragment(SPair(symfrag_id, S4), frag)),
O(Eoh(S3)),
O(SymDecl(SPair(sym_name, S3), Default::default(),)),
O(SymDepStart(SPair(symdep_name, S3))),
O(Fragment(SPair(symfrag_id, S4), frag)),
O(Eoh(S3)),
]),
sut.filter(|parsed| match parsed {
Ok(Incomplete) => false,

View File

@ -80,6 +80,20 @@ where
XirfToken::Close(qname.map(ExpectInto::unwrap_into), span.into(), depth)
}
/// Hastily and lazily produce a [`XirfToken::Attr`].
///
/// This function is intended for testing only.
pub fn attr<Q: TryInto<QName>, T: TextType>(
qname: Q,
value: SymbolId,
spans: (Span, Span),
) -> XirfToken<T>
where
<Q as TryInto<QName>>::Error: Debug,
{
XirfToken::Attr(Attr::new(qname.unwrap_into(), value, spans))
}
#[test]
fn empty_element_self_close() {
let name = ("ns", "elem");