aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/tests/builder/argument_builder_test.rs
blob: 178a383b2ebecba8bc26dea8f396a76eed40e01b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::rc::Rc;

use azalea_brigadier::{builder::argument_builder::ArgumentBuilder, prelude::*};

#[test]
fn test_arguments() {
    let builder: ArgumentBuilder<()> = literal("foo");

    let argument: ArgumentBuilder<()> = argument("bar", integer());
    let builder = builder.then(argument.clone());
    assert_eq!(builder.arguments().children.len(), 1);
    let built_argument = Rc::new(argument.build());
    assert!(
        builder
            .arguments()
            .children
            .values()
            .any(|e| *e.read() == *built_argument)
    );
}

//     @Test
//     public void testRedirect() throws Exception {
//         final CommandNode<Object> target = mock(CommandNode.class);
//         builder.redirect(target);
//         assertThat(builder.getRedirect(), is(target));
//     }

//     @Test(expected = IllegalStateException.class)
//     public void testRedirect_withChild() throws Exception {
//         final CommandNode<Object> target = mock(CommandNode.class);
//         builder.then(literal("foo"));
//         builder.redirect(target);
//     }

//     @Test(expected = IllegalStateException.class)
//     public void testThen_withRedirect() throws Exception {
//         final CommandNode<Object> target = mock(CommandNode.class);
//         builder.redirect(target);
//         builder.then(literal("foo"));
//     }

//     private static class TestableArgumentBuilder<S> extends
// ArgumentBuilder<S, TestableArgumentBuilder<S>> {         @Override
//         protected TestableArgumentBuilder<S> getThis() {
//             return this;
//         }

//         @Override
//         public CommandNode<S> build() {
//             return null;
//         }
//     }
// }