Start making representation work

This commit is contained in:
Greg Shuflin
2023-02-25 03:00:29 -08:00
parent 377d515d40
commit 5aca3912fc
6 changed files with 16 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ use parser_combinator::combinators::repeated;
use parser_combinator::primitives::{any_char, literal, literal_char, one_of, pred};
use parser_combinator::sequence::seq;
use parser_combinator::Parser;
use parser_combinator::Representation;
use proptest::prelude::*;
@@ -53,6 +54,7 @@ impl<'a, T, P> JsonParser<'a, T> for P where P: Parser<&'a str, T, &'a str> {}
fn json_null<'a>() -> impl JsonParser<'a, JsonValue> {
literal("null").to(JsonValue::Null)
}
fn json_bool<'a>() -> impl JsonParser<'a, JsonValue> {
choice((
literal("true").to(JsonValue::Bool(true)),
@@ -234,3 +236,8 @@ fn parse_json_document() {
let parsed_json = json_object().parse(test_json);
assert!(parsed_json.is_ok());
}
#[test]
fn test_representations() {
assert_eq!(json_null().representation(), Representation::new("null"));
}