Skip to content

Commit

Permalink
fix compilation error for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rszyma committed Aug 2, 2023
1 parent ed4eb1e commit e873bce
Showing 1 changed file with 83 additions and 38 deletions.
121 changes: 83 additions & 38 deletions parser/src/cfg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ fn span_works() {
let s = "(hello world my oyster)\n(row two)";
let tlevel = parse(s, "test").unwrap();
assert_eq!(
&s[tlevel[0].span.start..tlevel[0].span.end],
&s[tlevel[0].span.start()..tlevel[0].span.end()],
"(hello world my oyster)"
);
assert_eq!(&s[tlevel[1].span.start..tlevel[1].span.end], "(row two)");
assert_eq!(
&s[tlevel[1].span.start()..tlevel[1].span.end()],
"(row two)"
);
}

#[test]
Expand Down Expand Up @@ -94,12 +97,19 @@ fn parse_action_vars() {
(defchords $e $one $1 $two)
(defchords $e2 $one ($one) $two)
"#;
parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
}

#[test]
Expand All @@ -115,12 +125,19 @@ fn parse_delegate_to_default_layer_yes() {
(deflayer base b)
(deflayer other _)
"#;
let res = parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
let res = parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
assert_eq!(
res.3[2][0][OsCode::KEY_A.as_u16() as usize],
Action::KeyCode(KeyCode::B),
Expand All @@ -140,12 +157,19 @@ fn parse_delegate_to_default_layer_yes_but_base_transparent() {
(deflayer base _)
(deflayer other _)
"#;
let res = parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
let res = parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
assert_eq!(
res.3[2][0][OsCode::KEY_A.as_u16() as usize],
Action::KeyCode(KeyCode::A),
Expand All @@ -165,12 +189,19 @@ fn parse_delegate_to_default_layer_no() {
(deflayer base b)
(deflayer other _)
"#;
let res = parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
let res = parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
assert_eq!(
res.3[2][0][OsCode::KEY_A.as_u16() as usize],
Action::KeyCode(KeyCode::A),
Expand Down Expand Up @@ -574,12 +605,19 @@ fn parse_switch() {
)
)
"#;
let res = parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
let res = parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap();
assert_eq!(
res.3[0][0][OsCode::KEY_A.as_u16() as usize],
Action::Switch(&Switch {
Expand Down Expand Up @@ -643,10 +681,17 @@ fn parse_switch_exceed_depth() {
)
)
"#;
parse_cfg_raw_string(source, &mut s, "test")
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap_err();
parse_cfg_raw_string(
source,
&mut s,
&PathBuf::from("test"),
&mut FileContentProvider {
get_file_content_fn: &mut |_| unimplemented!(),
},
)
.map_err(|e| {
eprintln!("{:?}", error_with_source(e));
""
})
.unwrap_err();
}

0 comments on commit e873bce

Please sign in to comment.