Lines
100 %
Functions
Branches
use super::with_article;
use crate::ast::WasmType;
use crate::error::ParseErrorDetails;
#[test]
fn the_article_follows_the_first_letter_of_the_noun() {
assert_eq!(with_article(WasmType::AnyRef), "an any");
assert_eq!(with_article("index"), "an index");
assert_eq!(with_article(WasmType::Ratio), "a ratio");
assert_eq!(with_article("scalar"), "a scalar");
}
fn an_undefined_labels_alias_names_the_function_that_ended() {
let err = super::Error::undefined_symbol("M (LABELS 7)");
assert!(
err.to_string()
.contains("M: a LABELS function does not outlive its form")
);
assert!(matches!(
super::Error::undefined_symbol("M"),
super::Error::UndefinedSymbol(_)
));
fn caret_column(input: &str, needle: &str) -> usize {
let start = input.find(needle).unwrap_or_default();
let details = ParseErrorDetails::new("x".to_string(), input.to_string(), start..start + 1);
let rendered = details.render(false);
let caret_row = rendered.lines().last().unwrap_or_default();
caret_row.find('^').unwrap_or_default() - " | ".len()
fn the_caret_column_counts_characters_not_bytes() {
assert_eq!(
caret_column("(ok)\n(\u{0436}\u{0436}\u{0436} bad", "bad"),
5
fn an_offset_inside_a_multibyte_character_renders_without_panicking() {
let input = "(\u{0436}\u{0436} bad";
for start in 0..=input.len() + 2 {
assert!(details.render(false).contains('^'));
fn an_ascii_line_keeps_its_column() {
assert_eq!(caret_column("(abc bad", "bad"), 5);