Index: test/intl/break-iterator/en-break.js |
diff --git a/src/extensions/i18n/i18n-extension.h b/test/intl/break-iterator/en-break.js |
similarity index 64% |
copy from src/extensions/i18n/i18n-extension.h |
copy to test/intl/break-iterator/en-break.js |
index 050c336a67a21fd6cb32892e14215cac11971111..4ec77d34b9f357452e43a990a70f5fc6aede4fb7 100644 |
--- a/src/extensions/i18n/i18n-extension.h |
+++ b/test/intl/break-iterator/en-break.js |
@@ -26,26 +26,37 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
// limitations under the License. |
-#ifndef V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ |
-#define V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ |
- |
-#include "v8.h" |
- |
-namespace v8_i18n { |
- |
-class Extension : public v8::Extension { |
- public: |
- Extension(); |
- |
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
- v8::Handle<v8::String> name); |
- |
- static void Register(); |
- |
- private: |
- static Extension* extension_; |
-}; |
- |
-} // namespace v8_i18n |
- |
-#endif // V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ |
+// Segment plain English sentence and check results. |
+ |
+var iterator = new Intl.v8BreakIterator(['en']); |
+ |
+var textToSegment = 'Jack and Jill, went over hill, and got lost. Alert!'; |
+iterator.adoptText(textToSegment); |
+ |
+var slices = []; |
+var types = []; |
+var pos = iterator.first(); |
+while (pos !== -1) { |
+ var nextPos = iterator.next(); |
+ if (nextPos === -1) break; |
+ |
+ slices.push(textToSegment.slice(pos, nextPos)); |
+ types.push(iterator.breakType()); |
+ |
+ pos = nextPos; |
+} |
+ |
+assertEquals('Jack', slices[0]); |
+assertEquals(' ', slices[1]); |
+assertEquals('and', slices[2]); |
+assertEquals(' ', slices[3]); |
+assertEquals('Jill', slices[4]); |
+assertEquals(',', slices[5]); |
+assertEquals('!', slices[slices.length - 1]); |
+ |
+assertEquals('letter', types[0]); |
+assertEquals('none', types[1]); |
+assertEquals('letter', types[2]); |
+assertEquals('none', types[3]); |
+assertEquals('letter', types[4]); |
+assertEquals('none', types[types.length - 1]); |