void TwoByteStringUTF16Buffer::PushBack(uc32 ch) {
pos_--;
- ASSERT(pos_ >= 0 && raw_data_[pos_] == ch);
+ ASSERT(pos_ >= Scanner::kCharacterLookaheadBufferSize);
+ ASSERT(raw_data_[pos_ - Scanner::kCharacterLookaheadBufferSize] == ch);
}
static unibrow::Predicate<unibrow::LineTerminator, 128> kIsLineTerminator;
static unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace;
+ static const int kCharacterLookaheadBufferSize = 1;
+
private:
CharacterStreamUTF16Buffer char_stream_buffer_;
TwoByteStringUTF16Buffer two_byte_string_buffer_;
bool has_line_terminator_before_next_;
bool is_pre_parsing_;
- static const int kCharacterLookaheadBufferSize = 1;
-
// Literal buffer support
void StartLiteral();
void AddChar(uc32 ch);
}
+TEST(CompileExternalTwoByteSource) {
+ v8::HandleScope scope;
+ LocalContext context;
+
+ // This is a very short list of sources, which currently is to check for a
+ // regression caused by r2703.
+ const char* ascii_sources[] = {
+ "0.5",
+ "-0.5", // This mainly testes PushBack in the Scanner.
+ "--0.5", // This mainly testes PushBack in the Scanner.
+ NULL
+ };
+
+ // Compile the sources as external two byte strings.
+ for (int i = 0; ascii_sources[i] != NULL; i++) {
+ uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]);
+ UC16VectorResource uc16_resource(
+ i::Vector<const uint16_t>(two_byte_string, strlen(ascii_sources[i])));
+ v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource);
+ v8::Script::Compile(source);
+ }
+}
+
+
class RegExpStringModificationTest {
public:
RegExpStringModificationTest()