Created
April 3, 2021 16:02
-
-
Save mahmoudimus/7cdfad6e4572d49951eaaff81d31517c to your computer and use it in GitHub Desktop.
test harness for starlark modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
import com.google.common.truth.Truth; | |
import net.starlark.java.eval.EvalException; | |
import net.starlark.java.eval.Module; | |
import net.starlark.java.eval.Mutability; | |
import net.starlark.java.eval.Starlark; | |
import net.starlark.java.eval.StarlarkInt; | |
import net.starlark.java.eval.StarlarkList; | |
import net.starlark.java.eval.StarlarkSemantics; | |
import net.starlark.java.eval.StarlarkThread; | |
import net.starlark.java.syntax.FileOptions; | |
import net.starlark.java.syntax.ParserInput; | |
import net.starlark.java.syntax.SyntaxError; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
public class StarlarkModuleTest { | |
@Before | |
public void setUp() throws Exception { | |
} | |
@After | |
public void tearDown() throws Exception { | |
} | |
@Test | |
public void testModule() throws SyntaxError.Exception, EvalException, InterruptedException { | |
Module module = Module.create(); | |
try (Mutability mu = Mutability.create("test")) { | |
StarlarkThread thread = new StarlarkThread(mu, StarlarkSemantics.DEFAULT); | |
Starlark.execFile(ParserInput.fromLines("True = 123"), FileOptions.DEFAULT, module, thread); | |
} | |
Truth.assertThat(module.getGlobal("True")).isEqualTo(StarlarkInt.of(123)); | |
} | |
@Test | |
public void testMutability() { | |
Mutability mutability = Mutability.create("test"); | |
StarlarkList<String> list = StarlarkList.newList(mutability); | |
} | |
@Test | |
public void xxx() { | |
} | |
@Test | |
public void yyy() { | |
} | |
@Test | |
public void zzzz() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment