summaryrefslogtreecommitdiff
path: root/src/syntax/test.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-16 14:23:13 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-16 14:38:30 +0200
commit9f6137d8a829fe8f34554623495fa620252a0184 (patch)
treeda62c40caa247ac1825d335fde9350150c6604db /src/syntax/test.rs
parent84f30fb73518ca23cbc728b1bf414e80b344412a (diff)
Remove tuples and objects in favor of tables 🛢
This refactores the parser tests to make them more concise and flexible with regards to spans.
Diffstat (limited to 'src/syntax/test.rs')
-rw-r--r--src/syntax/test.rs73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/syntax/test.rs b/src/syntax/test.rs
deleted file mode 100644
index aec54ded..00000000
--- a/src/syntax/test.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use std::fmt::Debug;
-
-use crate::func::prelude::*;
-use super::tree::SyntaxNode;
-use super::span;
-
-pub fn check<T>(src: &str, exp: T, found: T, cmp_spans: bool)
-where
- T: Debug + PartialEq,
-{
- span::set_cmp(cmp_spans);
- let equal = exp == found;
- span::set_cmp(true);
-
- if !equal {
- println!("source: {:?}", src);
- println!("expected: {:#?}", exp);
- println!("found: {:#?}", found);
- panic!("test failed");
- }
-}
-
-/// Create a vector of optionally spanned expressions from a list description.
-///
-/// # Examples
-/// ```
-/// // With spans
-/// spanned![(0:0, 0:5, "hello"), (0:5, 0:3, "world")]
-///
-/// // Without spans: Implicit zero spans.
-/// spanned!["hello", "world"]
-/// ```
-macro_rules! span_vec {
- ($(($sl:tt:$sc:tt, $el:tt:$ec:tt, $v:expr)),* $(,)?) => {
- (vec![$(span_item!(($sl:$sc, $el:$ec, $v))),*], true)
- };
-
- ($($v:expr),* $(,)?) => {
- (vec![$(span_item!($v)),*], false)
- };
-}
-
-macro_rules! span_item {
- (($sl:tt:$sc:tt, $el:tt:$ec:tt, $v:expr)) => {{
- use $crate::syntax::span::{Pos, Span, Spanned};
- Spanned {
- span: Span::new(
- Pos::new($sl, $sc),
- Pos::new($el, $ec)
- ),
- v: $v
- }
- }};
-
- ($v:expr) => {
- $crate::syntax::span::Spanned::zero($v)
- };
-}
-
-pub fn debug_func(mut call: FuncCall, _: &ParseState) -> Pass<SyntaxNode> {
- let tree = call.args.pos.get::<SyntaxTree>();
- Pass::node(DebugNode(call, tree), Feedback::new())
-}
-
-#[derive(Debug, Clone, PartialEq)]
-pub struct DebugNode(pub FuncCall, pub Option<SyntaxTree>);
-
-#[async_trait(?Send)]
-impl Layout for DebugNode {
- async fn layout<'a>(&'a self, _: LayoutContext<'_>) -> Pass<Commands<'a>> {
- unimplemented!()
- }
-}