use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class MagicCommandResultOrderTest method classpathShouldBeLast.
@Test
public void classpathShouldBeLast() {
// given
String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains(DEMO_JAR);
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class MagicCommandResultOrderTest method codeResultShouldBeLast.
@Test
public void codeResultShouldBeLast() {
// given
String allCode = "" + "%classpath add jar " + DOC_CONTENTS_DEMO_RESOURCES_BEAKERX_TEST_LIBRARY_JAR + "\n" + "%classpath\n" + "code code code";
// when
Code code = CodeFactory.create(allCode, new Message(), kernel);
code.execute(kernel, 1);
// then
PlainCode actual = (PlainCode) code.getCodeFrames().get(2);
assertThat(actual.getPlainCode()).isEqualTo("code code code");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class TimeItLineModeMagicCommandTest method timeitLineMode.
@Test
public void timeitLineMode() {
// given
String allCode = "%timeit -r3 -n1 sleep(1)";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains("loop");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ClasspathMagicCommandTest method handleClasspathAddJarWildcardMagicCommand.
@Test
public void handleClasspathAddJarWildcardMagicCommand() {
// given
String allCode = "" + CLASSPATH_ADD_JAR + " " + SRC_TEST_RESOURCES + "dirWithTwoJars/*";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains(FOO_JAR, "bar.jar");
assertThat(evaluator.getResetEnvironmentCounter()).isEqualTo(0);
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ClasspathMagicCommandTest method showClasspath.
@Test
public void showClasspath() {
// given
kernel.addJarsToClasspath(asList(new PathToJar(CLASSPATH_TO_JAR_PATH)));
Code code = CodeFactory.create("%classpath", new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains(FOO_JAR);
}
Aggregations