зеркало из https://github.com/mozilla/pluotsorbet.git
Use "th.check()" in the added StringBuffer tests.
This commit is contained in:
Родитель
7217c02efe
Коммит
3adde8cc87
20
LICENSE
20
LICENSE
|
@ -248,3 +248,23 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
---
|
||||
|
||||
tests/gnu/testlet/vm/StringBufferTest.java (additional tests): Apache
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
|
|
|
@ -539,7 +539,8 @@ Override.simple("java/lang/StringBuffer.delete.(II)Ljava/lang/StringBuffer;",
|
|||
stringBufferDelete);
|
||||
|
||||
Override.simple("java/lang/StringBuffer.deleteCharAt.(I)Ljava/lang/StringBuffer;", function(index) {
|
||||
if (index < 0 || index >= this.count) {
|
||||
if (index >= this.count) {
|
||||
// stringBufferDelete handles the other boundary checks; this check is specific to deleteCharAt.
|
||||
throw new JavaException("java/lang/StringIndexOutOfBoundsException");
|
||||
}
|
||||
return stringBufferDelete.call(this, index, index + 1);
|
||||
|
|
|
@ -36,7 +36,7 @@ casper.test.begin("unit tests", 5 + gfxTests.length, function(test) {
|
|||
casper
|
||||
.start("http://localhost:8000/index.html")
|
||||
.waitForText("DONE", function() {
|
||||
test.assertTextExists("DONE: 4912 pass, 0 fail, 168 known fail, 0 unknown pass", "run unit tests");
|
||||
test.assertTextExists("DONE: 4936 pass, 0 fail, 168 known fail, 0 unknown pass", "run unit tests");
|
||||
});
|
||||
|
||||
casper
|
||||
|
|
|
@ -28,12 +28,13 @@ import java.io.UnsupportedEncodingException;
|
|||
|
||||
class StringBufferTest implements Testlet {
|
||||
|
||||
private TestHarness th;
|
||||
public void test(TestHarness th) {
|
||||
this.th = th;
|
||||
th.check(test1(), 0);
|
||||
}
|
||||
|
||||
public int test1() {
|
||||
|
||||
try {
|
||||
new StringBuffer(-1);
|
||||
return 100;
|
||||
|
@ -539,37 +540,36 @@ class StringBufferTest implements Testlet {
|
|||
StringBuffer obj = new StringBuffer();
|
||||
try {
|
||||
obj.getChars(0, 0, new char[0], -1);
|
||||
return 1080;
|
||||
th.fail();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer("abcde");
|
||||
try {
|
||||
buffer.setLength(-1);
|
||||
return 1090;
|
||||
th.fail();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
if (!"abcde".equals(buffer.toString())) { return 1091; }
|
||||
th.check(buffer.toString(), "abcde");
|
||||
buffer.setLength(1);
|
||||
buffer.append('f');
|
||||
System.out.println(buffer.toString());
|
||||
if (!"af".equals(buffer.toString())) { return 1092; }
|
||||
th.check(buffer.toString(), "af");
|
||||
|
||||
buffer = new StringBuffer("abcde");
|
||||
buffer.setLength(3);
|
||||
buffer.append('f');
|
||||
if (!"abcf".equals(buffer.toString())) { return 1093; }
|
||||
th.check(buffer.toString(), "abcf");
|
||||
|
||||
buffer = new StringBuffer("abcde");
|
||||
buffer.setLength(2);
|
||||
try {
|
||||
buffer.charAt(3);
|
||||
return 1100;
|
||||
th.fail();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// Expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
buffer = new StringBuffer();
|
||||
|
@ -577,67 +577,59 @@ class StringBufferTest implements Testlet {
|
|||
buffer.setLength(2);
|
||||
buffer.setLength(5);
|
||||
for (int i = 2; i < 5; i++) {
|
||||
if (buffer.charAt(i) != '\u0000') {
|
||||
return 1101;
|
||||
}
|
||||
th.check('\u0000', buffer.charAt(i));
|
||||
}
|
||||
|
||||
buffer = new StringBuffer();
|
||||
buffer.append("abcdefg");
|
||||
buffer.delete(2, 4);
|
||||
buffer.setLength(7);
|
||||
if (buffer.charAt(0) != 'a') { return 1102; }
|
||||
if (buffer.charAt(1) != 'b') { return 1103; }
|
||||
if (buffer.charAt(2) != 'e') { return 1104; }
|
||||
if (buffer.charAt(3) != 'f') { return 1105; }
|
||||
if (buffer.charAt(4) != 'g') { return 1106; }
|
||||
th.check(buffer.charAt(0), 'a');
|
||||
th.check(buffer.charAt(1), 'b');
|
||||
th.check(buffer.charAt(2), 'e');
|
||||
th.check(buffer.charAt(3), 'f');
|
||||
th.check(buffer.charAt(4), 'g');
|
||||
for (int i = 5; i < 7; i++) {
|
||||
if (buffer.charAt(i) != '\u0000') {
|
||||
return 1107;
|
||||
}
|
||||
th.check('\u0000', buffer.charAt(i));
|
||||
}
|
||||
buffer = new StringBuffer();
|
||||
buffer.append("abcdefg");
|
||||
buffer.setLength(5);
|
||||
buffer.setLength(7);
|
||||
for (int i = 5; i < 7; i++) {
|
||||
if (buffer.charAt(i) != '\u0000') {
|
||||
return 1108;
|
||||
}
|
||||
th.check('\u0000', buffer.charAt(i));
|
||||
}
|
||||
|
||||
buffer = new StringBuffer();
|
||||
if (!"".equals(buffer.toString())) {
|
||||
return 1109;
|
||||
}
|
||||
th.check(buffer.toString(), "");
|
||||
buffer.append("abcde");
|
||||
if (!"abcde".equals(buffer.toString())) { return 1110; }
|
||||
th.check(buffer.toString(), "abcde");
|
||||
buffer.setLength(5);
|
||||
buffer.append("fghij");
|
||||
if (!"abcdefghij".equals(buffer.toString())) { return 1111; }
|
||||
th.check(buffer.toString(), "abcdefghij");
|
||||
|
||||
obj = new StringBuffer();
|
||||
try {
|
||||
obj.append(new char[0], -1, -1);
|
||||
return 1112;
|
||||
th.fail();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
obj = new StringBuffer();
|
||||
try {
|
||||
obj.append((char[]) null, -1, -1);
|
||||
return 1120;
|
||||
th.fail();
|
||||
} catch (NullPointerException e) {
|
||||
// expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
obj = new StringBuffer();
|
||||
try {
|
||||
obj.insert(-1, ' ');
|
||||
return 1130;
|
||||
th.fail();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// expected
|
||||
th.pass();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче