diff options
author | dmarting <dmarting@google.com> | 2017-09-12 22:07:08 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-13 19:06:14 +0200 |
commit | 8dacd1dde5ea348dfe1162ae27daf1f04b7b258d (patch) | |
tree | 3c6ea95b2abf067fc784dd023f80a6b173d184e1 /src/test | |
parent | 95e381bbc877ee367d72b8b42bf36c9b4be8711c (diff) |
Automated rollback of commit f5b8281f1f7599c67476663887db909a4206710e.
*** Reason for rollback ***
Read the wrong log, it is not timing out, actual failure.
*** Original change description ***
Open-source src/test/skylark/...
This was means to be open-sourced from the beginning but an error in our
set-up hide it from the open-source tree.
PiperOrigin-RevId: 168428572
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/skylark/BUILD | 60 | ||||
-rw-r--r-- | src/test/skylark/question.text | 1 | ||||
-rw-r--r-- | src/test/skylark/skylark_test.py | 34 | ||||
-rw-r--r-- | src/test/skylark/testdata/and_or_not.sky | 47 | ||||
-rw-r--r-- | src/test/skylark/testdata/equality.sky | 74 | ||||
-rw-r--r-- | src/test/skylark/testdata/int.sky | 69 |
6 files changed, 0 insertions, 285 deletions
diff --git a/src/test/skylark/BUILD b/src/test/skylark/BUILD deleted file mode 100644 index c22bf079d0..0000000000 --- a/src/test/skylark/BUILD +++ /dev/null @@ -1,60 +0,0 @@ -load( - "//tools/build_rules:test_rules.bzl", - "rule_test", - "file_test", -) - -package(default_visibility = ["//src:__subpackages__"]) - -filegroup( - name = "srcs", - srcs = glob(["**"]), -) - -py_test( - name = "skylark_test", - srcs = ["skylark_test.py"], - data = ["//src/main/java/com/google/devtools/skylark:Skylark"] + glob([ - "testdata/*", - ]), -) - -## Rest of the file should be moved somewhere else (under bazel/tools/). - -genrule( - name = "tone_below", - outs = [ - "g1", - "g2", - ], - cmd = "echo 48.9994 > $(location :g1) ; echo 97.9989 > $(location :g2)", -) - -rule_test( - name = "assert_tone_below_1", - generates = [ - "g1", - "g2", - ], - rule = "tone_below", -) - -file_test( - name = "question_content", - content = ("If you could ask a unique question to a computer during a Turing test, " + - "what would you ask?\n"), - file = "question.text", -) - -file_test( - name = "question_regexp", - file = "question.text", - regexp = "[eu]n[uchs questi]\\+on", -) - -file_test( - name = "question_regexp_1", - file = "question.text", - matches = 1, - regexp = "what would you ask", -) diff --git a/src/test/skylark/question.text b/src/test/skylark/question.text deleted file mode 100644 index 238bebb86e..0000000000 --- a/src/test/skylark/question.text +++ /dev/null @@ -1 +0,0 @@ -If you could ask a unique question to a computer during a Turing test, what would you ask? diff --git a/src/test/skylark/skylark_test.py b/src/test/skylark/skylark_test.py deleted file mode 100644 index 84a866f681..0000000000 --- a/src/test/skylark/skylark_test.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2017 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import subprocess -import unittest - - -class SkylarkTest(unittest.TestCase): - - def testSuccess(self): - binary_path = ( - "third_party/bazel/src/main/java/com/google/devtools/skylark/Skylark") - test_dir = "third_party/bazel/src/test/skylark/testdata/" - - tests = ["int.sky", "equality.sky", "and_or_not.sky"] - for t in tests: - print subprocess.check_output([binary_path, test_dir + t]) - - # TODO(laurentlb): Add support for negative tests (e.g. syntax errors). - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/skylark/testdata/and_or_not.sky b/src/test/skylark/testdata/and_or_not.sky deleted file mode 100644 index 53cfb98f68..0000000000 --- a/src/test/skylark/testdata/and_or_not.sky +++ /dev/null @@ -1,47 +0,0 @@ -def assert_eq(x, y): - if x != y: - fail("%r != %r" % (x, y)) - - -assert_eq(8 or 9, 8) -assert_eq(0 or 9, 9) -assert_eq(8 and 9, 9) -assert_eq(0 and 9, 0) - -assert_eq(1 and 2 or 3, 2) -assert_eq(0 and 2 or 3, 3) -assert_eq(1 and 0 or 3, 3) - -assert_eq(1 or 2 and 3, 1) -assert_eq(0 or 2 and 3, 3) -assert_eq(0 or 0 and 3, 0) -assert_eq(1 or 0 and 3, 1) - -assert_eq(None and 1, None) -assert_eq("" or 9, 9) -assert_eq("abc" or 9, "abc") - -# check that fail() is not evaluated -assert_eq(8 or fail("do not execute"), 8) -assert_eq(0 and fail("do not execute"), 0) - -assert_eq(not 1, False) -assert_eq(not "", True) - -assert_eq(not 0 + 0, True) -assert_eq(not 2 - 1, False) - -assert_eq(not (0 and 0), True) -assert_eq(not (1 or 0), False) - -assert_eq(0 and not 0, 0) -assert_eq(not 0 and 0, 0) - -assert_eq(1 and not 0, True) -assert_eq(not 0 or 0, True) - -assert_eq(not 1 or 0, 0) -assert_eq(not 1 or 1, 1) - -assert_eq(not [], True) -assert_eq(not {"a": 1}, False) diff --git a/src/test/skylark/testdata/equality.sky b/src/test/skylark/testdata/equality.sky deleted file mode 100644 index 0f72f61a29..0000000000 --- a/src/test/skylark/testdata/equality.sky +++ /dev/null @@ -1,74 +0,0 @@ -def assert_eq(x, y): - if x != y: - fail("%r != %r" % (x, y)) - - -# == operator -assert_eq(1 == 1, True) -assert_eq(1 == 2, False) -assert_eq('hello' == 'hel' + 'lo', True) -assert_eq('hello' == 'bye', False) -assert_eq(None == None, True) -assert_eq([1, 2] == [1, 2], True) -assert_eq([1, 2] == [2, 1], False) -assert_eq({'a': 1, 'b': 2} == {'b': 2, 'a': 1}, True) -assert_eq({'a': 1, 'b': 2} == {'a': 1}, False) -assert_eq({'a': 1, 'b': 2} == {'a': 1, 'b': 2, 'c': 3}, False) -assert_eq({'a': 1, 'b': 2} == {'a': 1, 'b': 3}, False) - -# != operator -assert_eq(1 != 1, False) -assert_eq(1 != 2, True) -assert_eq('hello' != 'hel' + 'lo', False) -assert_eq('hello' != 'bye', True) -assert_eq([1, 2] != [1, 2], False) -assert_eq([1, 2] != [2, 1], True) -assert_eq({'a': 1, 'b': 2} != {'b': 2, 'a': 1}, False) -assert_eq({'a': 1, 'b': 2} != {'a': 1}, True) -assert_eq({'a': 1, 'b': 2} != {'a': 1, 'b': 2, 'c': 3}, True) -assert_eq({'a': 1, 'b': 2} != {'a': 1, 'b': 3}, True); - -# equality precedence -assert_eq(1 + 3 == 2 + 2, True) -assert_eq(not 1 == 2, True) -assert_eq(not 1 != 2, False) -assert_eq(2 and 3 == 3 or 1, True) -assert_eq(2 or 3 == 3 and 1, 2); - -# < operator -assert_eq(1 <= 1, True) -assert_eq(1 < 1, False) -assert_eq('a' <= 'b', True) -assert_eq('c' < 'a', False); - -# <= and < operators -assert_eq(1 <= 1, True) -assert_eq(1 < 1, False) -assert_eq('a' <= 'b', True) -assert_eq('c' < 'a', False); - -# >= and > operators -assert_eq(1 >= 1, True) -assert_eq(1 > 1, False) -assert_eq('a' >= 'b', False) -assert_eq('c' > 'a', True); - -# list/tuple comparison -assert_eq([] < [1], True) -assert_eq([1] < [1, 1], True) -assert_eq([1, 1] < [1, 2], True) -assert_eq([1, 2] < [1, 2, 3], True) -assert_eq([1, 2, 3] <= [1, 2, 3], True) - -assert_eq(['a', 'b'] > ['a'], True) -assert_eq(['a', 'b'] >= ['a'], True) -assert_eq(['a', 'b'] < ['a'], False) -assert_eq(['a', 'b'] <= ['a'], False) - -assert_eq(('a', 'b') > ('a', 'b'), False) -assert_eq(('a', 'b') >= ('a', 'b'), True) -assert_eq(('a', 'b') < ('a', 'b'), False) -assert_eq(('a', 'b') <= ('a', 'b'), True) - -assert_eq([[1, 1]] > [[1, 1], []], False) -assert_eq([[1, 1]] < [[1, 1], []], True) diff --git a/src/test/skylark/testdata/int.sky b/src/test/skylark/testdata/int.sky deleted file mode 100644 index cd19f17669..0000000000 --- a/src/test/skylark/testdata/int.sky +++ /dev/null @@ -1,69 +0,0 @@ -# Tests of Skylark 'int' - -def assert_eq(x, y): - if x != y: - fail("%r != %r" % (x, y)) - -def assert_(cond, msg="assertion failed"): - if not cond: - fail(msg) - -# basic arithmetic -assert_eq(0 - 1, -1) -assert_eq(1 + 1, 2) -assert_eq(5 + 7, 12) -assert_eq(5 * 7, 35) -assert_eq(5 - 7, -2) - -# truth -assert_(123) -assert_(-1) -assert_(not 0) - -# comparisons -assert_(5 > 2) -assert_(2 + 1 == 3) -assert_(2 + 1 >= 3) -assert_(not (2 + 1 > 3)) -assert_(2 + 2 <= 5) -assert_(not (2 + 1 < 3)) - -# division -assert_eq(100 // 7, 14) -assert_eq(100 // -7, -15) -assert_eq(-100 // 7, -15) # NB: different from Go / Java -assert_eq(-100 // -7, 14) # NB: different from Go / Java -assert_eq(98 // 7, 14) -assert_eq(98 // -7, -14) -assert_eq(-98 // 7, -14) -assert_eq(-98 // -7, 14) - -# remainder -assert_eq(100 % 7, 2) -assert_eq(100 % -7, -5) # NB: different from Go / Java -assert_eq(-100 % 7, 5) # NB: different from Go / Java -assert_eq(-100 % -7, -2) -assert_eq(98 % 7, 0) -assert_eq(98 % -7, 0) -assert_eq(-98 % 7, 0) -assert_eq(-98 % -7, 0) - -# precedence -assert_eq(5 - 7 * 2 + 3, -6) -assert_eq(4 * 5 / 2 + 5 / 2 * 4, 18) - -# compound assignment -def compound(): - x = 1 - x += 1 - assert_eq(x, 2) - x -= 3 - assert_eq(x, -1) - x *= 10 - assert_eq(x, -10) - x /= -2 - assert_eq(x, 5) - x %= 3 - assert_eq(x, 2) - -compound() |