changeset 8260:641cdd0f39c8

imported patch 8012665
author henryjen
date Fri, 19 Apr 2013 14:59:28 -0700
parents 96be5e1ae7d5
children 7343ad140bc9
files src/share/classes/java/lang/CharSequence.java test-ng/tests/org/openjdk/tests/java/lang/CharSequenceStreamTest.java test/java/lang/CharSequence/DefaultTest.java
diffstat 3 files changed, 98 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/CharSequence.java	Fri Apr 19 14:45:28 2013 -0700
+++ b/src/share/classes/java/lang/CharSequence.java	Fri Apr 19 14:59:28 2013 -0700
@@ -119,7 +119,7 @@
      * Returns a stream of char values from this sequence. If the sequence is
      * mutated while the stream is being read, the result is undefined.
      *
-     * @return an Iterable of Character values from this sequence
+     * @return an IntStream of {@code char} values from this sequence
      */
     public default IntStream chars() {
         class CharIterator implements PrimitiveIterator.OfInt {
@@ -160,7 +160,7 @@
      * If the sequence is mutated while the stream is being read, the result
      * is undefined.
      *
-     * @return an Iterable of Unicode code points from this sequence
+     * @return an IntStream of Unicode code points from this sequence
      */
     public default IntStream codePoints() {
         class CodePointIterator implements PrimitiveIterator.OfInt {
--- a/test-ng/tests/org/openjdk/tests/java/lang/CharSequenceStreamTest.java	Fri Apr 19 14:45:28 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.openjdk.tests.java.lang;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.PrimitiveIterator;
-import java.util.stream.Collectors;
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.*;
-
-@Test(groups = "lib")
-public class CharSequenceStreamTest {
-
-    @Test(expectedExceptions = NoSuchElementException.class)
-    public void testEmptyChars() {
-        PrimitiveIterator.OfInt s = "".chars().iterator();
-        assertFalse(s.hasNext());
-        int ch = s.nextInt();
-    }
-
-    public void testSimpleChars() {
-        List<Integer> list = "abc".chars().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList((int) 'a', (int) 'b', (int) 'c'));
-    }
-
-    @Test(expectedExceptions = NoSuchElementException.class)
-    public void testEmptyCodePoints() {
-        PrimitiveIterator.OfInt s = "".codePoints().iterator();
-        assertFalse(s.hasNext());
-        int cp = s.nextInt();
-    }
-
-    public void testSimpleCodePoints() {
-        List<Integer> list = "abc".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList((int)'a', (int)'b', (int)'c'));
-    }
-
-    public void testUndefCodePoints() {
-        List<Integer> list = "X\ufffeY".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList((int)'X', 0xFFFE, (int)'Y'));
-    }
-
-    public void testSurrogatePairing() {
-        // U+1D11E = MUSICAL SYMBOL G CLEF
-        // equivalent to surrogate pair U+D834 U+DD1E
-        List<Integer> list;
-        final int GCLEF = 0x1d11e;
-
-        list = "\ud834\udd1e".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList(GCLEF));
-        list = "A\ud834\udd1e".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList((int)'A', GCLEF));
-        list = "\ud834\udd1eB".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList(GCLEF, (int)'B'));
-        list = "X\ud834\udd1eY".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList((int)'X', GCLEF, (int)'Y'));
-    }
-
-    public void testUndefUnpaired() {
-        List<Integer> list = "W\udd1eX\ud834Y\ufffeZ".codePoints().boxed().collect(Collectors.toList());
-        assertEquals(list, Arrays.asList(
-            (int)'W', 0xdd1e, (int)'X', 0xd834, (int)'Y', 0xfffe, (int)'Z'));
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/CharSequence/DefaultTest.java	Fri Apr 19 14:59:28 2013 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.stream.Collectors;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+/*
+ * @test
+ * @summary Unit test for CharSequence default methods
+ * @bug 8012665
+ * @run testng DefaultTest
+ */
+
+@Test(groups = "lib")
+public class DefaultTest {
+
+    @Test(expectedExceptions = NoSuchElementException.class)
+    public void testEmptyChars() {
+        PrimitiveIterator.OfInt s = "".chars().iterator();
+        assertFalse(s.hasNext());
+        int ch = s.nextInt();
+    }
+
+    public void testSimpleChars() {
+        List<Integer> list = "abc".chars().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList((int) 'a', (int) 'b', (int) 'c'));
+    }
+
+    @Test(expectedExceptions = NoSuchElementException.class)
+    public void testEmptyCodePoints() {
+        PrimitiveIterator.OfInt s = "".codePoints().iterator();
+        assertFalse(s.hasNext());
+        int cp = s.nextInt();
+    }
+
+    public void testSimpleCodePoints() {
+        List<Integer> list = "abc".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList((int)'a', (int)'b', (int)'c'));
+    }
+
+    public void testUndefCodePoints() {
+        List<Integer> list = "X\ufffeY".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList((int)'X', 0xFFFE, (int)'Y'));
+    }
+
+    public void testSurrogatePairing() {
+        // U+1D11E = MUSICAL SYMBOL G CLEF
+        // equivalent to surrogate pair U+D834 U+DD1E
+        List<Integer> list;
+        final int GCLEF = 0x1d11e;
+
+        list = "\ud834\udd1e".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList(GCLEF));
+        list = "A\ud834\udd1e".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList((int)'A', GCLEF));
+        list = "\ud834\udd1eB".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList(GCLEF, (int)'B'));
+        list = "X\ud834\udd1eY".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList((int)'X', GCLEF, (int)'Y'));
+    }
+
+    public void testUndefUnpaired() {
+        List<Integer> list = "W\udd1eX\ud834Y\ufffeZ".codePoints().boxed().collect(Collectors.toList());
+        assertEquals(list, Arrays.asList(
+            (int)'W', 0xdd1e, (int)'X', 0xd834, (int)'Y', 0xfffe, (int)'Z'));
+    }
+}