MCPcopy Create free account
hub / github.com/Glyphack/enderpy / test_constant_value_get_source

Function test_constant_value_get_source

parser/src/parser/parser.rs:3977–4000  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3975
3976 #[test]
3977 fn test_constant_value_get_source() {
3978 for source in &[
3979 "\"hello\"",
3980 "'hello'",
3981 "'''hello'''",
3982 "\"\"\"hello\"\"\"",
3983 "'he' \"\"\"l\"\"\" \"l\" 'o'",
3984 ] {
3985 let mut parser = Parser::new(source);
3986 let module = parser.parse().unwrap();
3987
3988 let constant_value = module
3989 .body
3990 .first()
3991 .unwrap()
3992 .clone()
3993 .expect_expression_statement()
3994 .expect_constant();
3995
3996 let value = constant_value.get_value(source);
3997 dbg!(&value);
3998 assert!(value.eq("hello"));
3999 }
4000 }
4001
4002 macro_rules! parser_test {
4003 ($test_name:ident, $test_file:expr) => {

Callers

nothing calls this directly

Calls 2

parseMethod · 0.80
get_valueMethod · 0.80

Tested by

no test coverage detected