aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2016-10-14 13:39:45 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-10-14 20:24:36 +0000
commit5e99198c66443e0298b406212c1e80a55fc729aa (patch)
tree24d07c8be044839bf9fea05d9751c70ad14804c1 /src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
parentf50e6691da8aa685f31165c66a245b85f68abf06 (diff)
Cleanup, remove differences between Build and Skylark environments.
The only visible difference for users is that a few more functions are available in BUILD files. That's fine, this difference was not even documented. RELNOTES: A few functions are added to BUILD files for consistency (hash, dir, hasattr, getattr) with .bzl files, although they are not very useful. -- MOS_MIGRATED_REVID=136151633
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java92
1 files changed, 78 insertions, 14 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
index f38695c0e7..1e8ae71195 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EnvironmentTest.java
@@ -100,10 +100,12 @@ public class EnvironmentTest extends EvaluationTestCase {
Environment outerEnv;
Environment innerEnv;
try (Mutability mut = Mutability.create("outer")) {
- outerEnv = Environment.builder(mut)
- .setGlobals(Environment.BUILD).build()
- .update("foo", "bar")
- .update("wiz", 3);
+ outerEnv =
+ Environment.builder(mut)
+ .setGlobals(Environment.DEFAULT_GLOBALS)
+ .build()
+ .update("foo", "bar")
+ .update("wiz", 3);
}
try (Mutability mut = Mutability.create("inner")) {
innerEnv = Environment.builder(mut)
@@ -112,15 +114,74 @@ public class EnvironmentTest extends EvaluationTestCase {
.update("quux", 42);
}
- assertEquals(Sets.newHashSet("foo", "wiz",
- "False", "None", "True",
- "-", "all", "any", "bool", "dict", "enumerate", "fail", "int", "len", "list", "max",
- "min", "print", "range", "repr", "reversed", "select", "set", "sorted", "str", "zip"),
+ assertEquals(
+ Sets.newHashSet(
+ "foo",
+ "wiz",
+ "False",
+ "None",
+ "True",
+ "-",
+ "all",
+ "any",
+ "bool",
+ "dict",
+ "dir",
+ "enumerate",
+ "fail",
+ "getattr",
+ "hasattr",
+ "hash",
+ "int",
+ "len",
+ "list",
+ "max",
+ "min",
+ "print",
+ "range",
+ "repr",
+ "reversed",
+ "select",
+ "set",
+ "sorted",
+ "str",
+ "type",
+ "zip"),
outerEnv.getVariableNames());
- assertEquals(Sets.newHashSet("foo", "wiz", "quux",
- "False", "None", "True",
- "-", "all", "any", "bool", "dict", "enumerate", "fail", "int", "len", "list", "max",
- "min", "print", "range", "repr", "reversed", "select", "set", "sorted", "str", "zip"),
+ assertEquals(
+ Sets.newHashSet(
+ "foo",
+ "wiz",
+ "quux",
+ "False",
+ "None",
+ "True",
+ "-",
+ "all",
+ "any",
+ "bool",
+ "dict",
+ "dir",
+ "enumerate",
+ "fail",
+ "getattr",
+ "hasattr",
+ "hash",
+ "int",
+ "len",
+ "list",
+ "max",
+ "min",
+ "print",
+ "range",
+ "repr",
+ "reversed",
+ "select",
+ "set",
+ "sorted",
+ "str",
+ "type",
+ "zip"),
innerEnv.getVariableNames());
}
@@ -145,8 +206,11 @@ public class EnvironmentTest extends EvaluationTestCase {
public void testFrozen() throws Exception {
Environment env;
try (Mutability mutability = Mutability.create("testFrozen")) {
- env = Environment.builder(mutability)
- .setGlobals(Environment.BUILD).setEventHandler(Environment.FAIL_FAST_HANDLER).build();
+ env =
+ Environment.builder(mutability)
+ .setGlobals(Environment.DEFAULT_GLOBALS)
+ .setEventHandler(Environment.FAIL_FAST_HANDLER)
+ .build();
env.update("x", 1);
assertEquals(env.lookup("x"), 1);
env.update("y", 2);