Exemple #1
0
  @Test
  public void shouldAllowTheSettingOfTheEnvironment() {
    assertThat(Environment.get(), is(nullValue()));
    assertThat(Environment.is(null), is(true));
    assertThat(Environment.is("anything else"), is(false));

    Environment.set("test");

    assertThat(Environment.get(), is("test"));
    assertThat(Environment.is("test"), is(true));
    assertThat(Environment.is(null), is(false));
    assertThat(Environment.is("Test"), is(false));

    Environment.set("test2");

    assertThat(Environment.get(), is("test2"));
    assertThat(Environment.is("test2"), is(true));
    assertThat(Environment.is("test"), is(false));
  }
Exemple #2
0
  @Override
  public Object evaluate(Environment environment) {
    Environment closure = new Environment(environment);

    for (int i = 0; i < getNumberOfArguments(); i++) {
      closure.set(variableNames[i], getArgument(i).evaluate(environment));
    }

    Node functionBody = environment.get(Node.class, functionName);
    return functionBody.evaluate(closure);
  }
Exemple #3
0
 @After
 public void after() {
   Environment.set(null);
 }