Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: test/mjsunit/string-indexof-1.js

Issue 7826007: Added check for trailing whitespaces and corrected existing violations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Yet another iteration. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/string-compare-alignment.js ('k') | test/mjsunit/string-indexof-2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // Random greek letters 57 // Random greek letters
58 var twoByteString = "\u039a\u0391\u03a3\u03a3\u0395"; 58 var twoByteString = "\u039a\u0391\u03a3\u03a3\u0395";
59 59
60 // Test single char pattern 60 // Test single char pattern
61 assertEquals(0, twoByteString.indexOf("\u039a"), "Lamda"); 61 assertEquals(0, twoByteString.indexOf("\u039a"), "Lamda");
62 assertEquals(1, twoByteString.indexOf("\u0391"), "Alpha"); 62 assertEquals(1, twoByteString.indexOf("\u0391"), "Alpha");
63 assertEquals(2, twoByteString.indexOf("\u03a3"), "First Sigma"); 63 assertEquals(2, twoByteString.indexOf("\u03a3"), "First Sigma");
64 assertEquals(3, twoByteString.indexOf("\u03a3",3), "Second Sigma"); 64 assertEquals(3, twoByteString.indexOf("\u03a3",3), "Second Sigma");
65 assertEquals(4, twoByteString.indexOf("\u0395"), "Epsilon"); 65 assertEquals(4, twoByteString.indexOf("\u0395"), "Epsilon");
66 assertEquals(-1, twoByteString.indexOf("\u0392"), "Not beta"); 66 assertEquals(-1, twoByteString.indexOf("\u0392"), "Not beta");
67 67
68 // Test multi-char pattern 68 // Test multi-char pattern
69 assertEquals(0, twoByteString.indexOf("\u039a\u0391"), "lambda Alpha"); 69 assertEquals(0, twoByteString.indexOf("\u039a\u0391"), "lambda Alpha");
70 assertEquals(1, twoByteString.indexOf("\u0391\u03a3"), "Alpha Sigma"); 70 assertEquals(1, twoByteString.indexOf("\u0391\u03a3"), "Alpha Sigma");
71 assertEquals(2, twoByteString.indexOf("\u03a3\u03a3"), "Sigma Sigma"); 71 assertEquals(2, twoByteString.indexOf("\u03a3\u03a3"), "Sigma Sigma");
72 assertEquals(3, twoByteString.indexOf("\u03a3\u0395"), "Sigma Epsilon"); 72 assertEquals(3, twoByteString.indexOf("\u03a3\u0395"), "Sigma Epsilon");
73 73
74 assertEquals(-1, twoByteString.indexOf("\u0391\u03a3\u0395"), 74 assertEquals(-1, twoByteString.indexOf("\u0391\u03a3\u0395"),
75 "Not Alpha Sigma Epsilon"); 75 "Not Alpha Sigma Epsilon");
76 76
77 //single char pattern 77 //single char pattern
78 assertEquals(4, twoByteString.indexOf("\u0395")); 78 assertEquals(4, twoByteString.indexOf("\u0395"));
79 79
80 // Test complex string indexOf algorithms. Only trigger for long strings. 80 // Test complex string indexOf algorithms. Only trigger for long strings.
81 81
82 // Long string that isn't a simple repeat of a shorter string. 82 // Long string that isn't a simple repeat of a shorter string.
83 var long = "A"; 83 var long = "A";
84 for(var i = 66; i < 76; i++) { // from 'B' to 'K' 84 for(var i = 66; i < 76; i++) { // from 'B' to 'K'
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 var lengths = [1, 4, 15]; // Single char, simple and complex. 116 var lengths = [1, 4, 15]; // Single char, simple and complex.
117 var indices = [0x5, 0x65, 0x85, 0x105, 0x205, 0x285, 0x2005, 0x2085, 0xfff0]; 117 var indices = [0x5, 0x65, 0x85, 0x105, 0x205, 0x285, 0x2005, 0x2085, 0xfff0];
118 for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { 118 for (var lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
119 var length = lengths[lengthIndex]; 119 var length = lengths[lengthIndex];
120 for (var i = 0; i < indices.length; i++) { 120 for (var i = 0; i < indices.length; i++) {
121 var index = indices[i]; 121 var index = indices[i];
122 var pattern = allCharsString.substring(index, index + length); 122 var pattern = allCharsString.substring(index, index + length);
123 assertEquals(index, allCharsString.indexOf(pattern)); 123 assertEquals(index, allCharsString.indexOf(pattern));
124 } 124 }
125 } 125 }
OLDNEW
« no previous file with comments | « test/mjsunit/string-compare-alignment.js ('k') | test/mjsunit/string-indexof-2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698