зеркало из 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
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
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);
|
stringBufferDelete);
|
||||||
|
|
||||||
Override.simple("java/lang/StringBuffer.deleteCharAt.(I)Ljava/lang/StringBuffer;", function(index) {
|
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");
|
throw new JavaException("java/lang/StringIndexOutOfBoundsException");
|
||||||
}
|
}
|
||||||
return stringBufferDelete.call(this, index, index + 1);
|
return stringBufferDelete.call(this, index, index + 1);
|
||||||
|
|
|
@ -36,7 +36,7 @@ casper.test.begin("unit tests", 5 + gfxTests.length, function(test) {
|
||||||
casper
|
casper
|
||||||
.start("http://localhost:8000/index.html")
|
.start("http://localhost:8000/index.html")
|
||||||
.waitForText("DONE", function() {
|
.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
|
casper
|
||||||
|
|
|
@ -28,12 +28,13 @@ import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
class StringBufferTest implements Testlet {
|
class StringBufferTest implements Testlet {
|
||||||
|
|
||||||
|
private TestHarness th;
|
||||||
public void test(TestHarness th) {
|
public void test(TestHarness th) {
|
||||||
|
this.th = th;
|
||||||
th.check(test1(), 0);
|
th.check(test1(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int test1() {
|
public int test1() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new StringBuffer(-1);
|
new StringBuffer(-1);
|
||||||
return 100;
|
return 100;
|
||||||
|
@ -539,37 +540,36 @@ class StringBufferTest implements Testlet {
|
||||||
StringBuffer obj = new StringBuffer();
|
StringBuffer obj = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
obj.getChars(0, 0, new char[0], -1);
|
obj.getChars(0, 0, new char[0], -1);
|
||||||
return 1080;
|
th.fail();
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
// expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer("abcde");
|
StringBuffer buffer = new StringBuffer("abcde");
|
||||||
try {
|
try {
|
||||||
buffer.setLength(-1);
|
buffer.setLength(-1);
|
||||||
return 1090;
|
th.fail();
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"abcde".equals(buffer.toString())) { return 1091; }
|
th.check(buffer.toString(), "abcde");
|
||||||
buffer.setLength(1);
|
buffer.setLength(1);
|
||||||
buffer.append('f');
|
buffer.append('f');
|
||||||
System.out.println(buffer.toString());
|
th.check(buffer.toString(), "af");
|
||||||
if (!"af".equals(buffer.toString())) { return 1092; }
|
|
||||||
|
|
||||||
buffer = new StringBuffer("abcde");
|
buffer = new StringBuffer("abcde");
|
||||||
buffer.setLength(3);
|
buffer.setLength(3);
|
||||||
buffer.append('f');
|
buffer.append('f');
|
||||||
if (!"abcf".equals(buffer.toString())) { return 1093; }
|
th.check(buffer.toString(), "abcf");
|
||||||
|
|
||||||
buffer = new StringBuffer("abcde");
|
buffer = new StringBuffer("abcde");
|
||||||
buffer.setLength(2);
|
buffer.setLength(2);
|
||||||
try {
|
try {
|
||||||
buffer.charAt(3);
|
buffer.charAt(3);
|
||||||
return 1100;
|
th.fail();
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// Expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
|
@ -577,67 +577,59 @@ class StringBufferTest implements Testlet {
|
||||||
buffer.setLength(2);
|
buffer.setLength(2);
|
||||||
buffer.setLength(5);
|
buffer.setLength(5);
|
||||||
for (int i = 2; i < 5; i++) {
|
for (int i = 2; i < 5; i++) {
|
||||||
if (buffer.charAt(i) != '\u0000') {
|
th.check('\u0000', buffer.charAt(i));
|
||||||
return 1101;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
buffer.append("abcdefg");
|
buffer.append("abcdefg");
|
||||||
buffer.delete(2, 4);
|
buffer.delete(2, 4);
|
||||||
buffer.setLength(7);
|
buffer.setLength(7);
|
||||||
if (buffer.charAt(0) != 'a') { return 1102; }
|
th.check(buffer.charAt(0), 'a');
|
||||||
if (buffer.charAt(1) != 'b') { return 1103; }
|
th.check(buffer.charAt(1), 'b');
|
||||||
if (buffer.charAt(2) != 'e') { return 1104; }
|
th.check(buffer.charAt(2), 'e');
|
||||||
if (buffer.charAt(3) != 'f') { return 1105; }
|
th.check(buffer.charAt(3), 'f');
|
||||||
if (buffer.charAt(4) != 'g') { return 1106; }
|
th.check(buffer.charAt(4), 'g');
|
||||||
for (int i = 5; i < 7; i++) {
|
for (int i = 5; i < 7; i++) {
|
||||||
if (buffer.charAt(i) != '\u0000') {
|
th.check('\u0000', buffer.charAt(i));
|
||||||
return 1107;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
buffer.append("abcdefg");
|
buffer.append("abcdefg");
|
||||||
buffer.setLength(5);
|
buffer.setLength(5);
|
||||||
buffer.setLength(7);
|
buffer.setLength(7);
|
||||||
for (int i = 5; i < 7; i++) {
|
for (int i = 5; i < 7; i++) {
|
||||||
if (buffer.charAt(i) != '\u0000') {
|
th.check('\u0000', buffer.charAt(i));
|
||||||
return 1108;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new StringBuffer();
|
buffer = new StringBuffer();
|
||||||
if (!"".equals(buffer.toString())) {
|
th.check(buffer.toString(), "");
|
||||||
return 1109;
|
|
||||||
}
|
|
||||||
buffer.append("abcde");
|
buffer.append("abcde");
|
||||||
if (!"abcde".equals(buffer.toString())) { return 1110; }
|
th.check(buffer.toString(), "abcde");
|
||||||
buffer.setLength(5);
|
buffer.setLength(5);
|
||||||
buffer.append("fghij");
|
buffer.append("fghij");
|
||||||
if (!"abcdefghij".equals(buffer.toString())) { return 1111; }
|
th.check(buffer.toString(), "abcdefghij");
|
||||||
|
|
||||||
obj = new StringBuffer();
|
obj = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
obj.append(new char[0], -1, -1);
|
obj.append(new char[0], -1, -1);
|
||||||
return 1112;
|
th.fail();
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
// expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = new StringBuffer();
|
obj = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
obj.append((char[]) null, -1, -1);
|
obj.append((char[]) null, -1, -1);
|
||||||
return 1120;
|
th.fail();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = new StringBuffer();
|
obj = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
obj.insert(-1, ' ');
|
obj.insert(-1, ' ');
|
||||||
return 1130;
|
th.fail();
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
// expected
|
th.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче