~ubuntu-branches/ubuntu/trusty/libv8/trusty

« back to all changes in this revision

Viewing changes to test/cctest/test-strings.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-02-20 14:08:17 UTC
  • mfrom: (15.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120220140817-bsvmeoa4sxsj5hbz
Tags: 3.7.12.22-3
Fix mipsel build, allow test debug-step-3 to fail (non-crucial)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006-2008 the V8 project authors. All rights reserved.
 
1
// Copyright 2011 the V8 project authors. All rights reserved.
2
2
 
3
3
// Check that we can traverse very deep stacks of ConsStrings using
4
4
// StringInputBuffer.  Check that Get(int) works on very deep stacks
502
502
}
503
503
 
504
504
 
 
505
class AsciiVectorResource : public v8::String::ExternalAsciiStringResource {
 
506
 public:
 
507
  explicit AsciiVectorResource(i::Vector<const char> vector)
 
508
      : data_(vector) {}
 
509
  virtual ~AsciiVectorResource() {}
 
510
  virtual size_t length() const { return data_.length(); }
 
511
  virtual const char* data() const { return data_.start(); }
 
512
 private:
 
513
  i::Vector<const char> data_;
 
514
};
 
515
 
 
516
 
 
517
TEST(SliceFromExternal) {
 
518
  FLAG_string_slices = true;
 
519
  InitializeVM();
 
520
  v8::HandleScope scope;
 
521
  AsciiVectorResource resource(
 
522
      i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
 
523
  Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource);
 
524
  CHECK(string->IsExternalString());
 
525
  Handle<String> slice = FACTORY->NewSubString(string, 1, 25);
 
526
  CHECK(slice->IsSlicedString());
 
527
  CHECK(string->IsExternalString());
 
528
  CHECK_EQ(SlicedString::cast(*slice)->parent(), *string);
 
529
  CHECK(SlicedString::cast(*slice)->parent()->IsExternalString());
 
530
  CHECK(slice->IsFlat());
 
531
}
 
532
 
 
533
 
505
534
TEST(TrivialSlice) {
506
535
  // This tests whether a slice that contains the entire parent string
507
536
  // actually creates a new string (it should not).