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

Side by Side Diff: runtime/vm/object_test.cc

Issue 1096433003: Fix List length size check; add test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 EXPECT_EQ(1, Object::zero_array().Length()); 1944 EXPECT_EQ(1, Object::zero_array().Length());
1945 element = Object::zero_array().At(0); 1945 element = Object::zero_array().At(0);
1946 EXPECT(Smi::Cast(element).IsZero()); 1946 EXPECT(Smi::Cast(element).IsZero());
1947 1947
1948 array.MakeImmutable(); 1948 array.MakeImmutable();
1949 Object& obj = Object::Handle(array.raw()); 1949 Object& obj = Object::Handle(array.raw());
1950 EXPECT(obj.IsArray()); 1950 EXPECT(obj.IsArray());
1951 } 1951 }
1952 1952
1953 1953
1954 TEST_CASE(ArrayLength) {
1955 const intptr_t kLength = Array::kMaxElements + 1;
Ivan Posva 2015/04/17 04:38:25 Please verify that this test passes with kMaxEleme
1956 ASSERT(kLength >= 0);
1957 char buffer[1024];
1958 OS::SNPrint(buffer, sizeof(buffer),
1959 "main() {\n"
1960 " new List(%" Pd ");\n"
1961 "}\n",
1962 kLength);
1963 Dart_Handle lib = TestCase::LoadTestScript(buffer, NULL);
1964 EXPECT_VALID(lib);
1965 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
1966 OS::SNPrint(buffer, sizeof(buffer),
1967 "Unhandled exception:\n"
1968 "Invalid argument(s): Length (%" Pd ") must be an integer "
1969 "in the range [0..%" Pd "].",
1970 kLength, Array::kMaxElements);
1971 EXPECT_ERROR(result, buffer);
1972 }
1973
1974
1954 TEST_CASE(StringCodePointIterator) { 1975 TEST_CASE(StringCodePointIterator) {
1955 const String& str0 = String::Handle(String::New("")); 1976 const String& str0 = String::Handle(String::New(""));
1956 String::CodePointIterator it0(str0); 1977 String::CodePointIterator it0(str0);
1957 EXPECT(!it0.Next()); 1978 EXPECT(!it0.Next());
1958 1979
1959 const String& str1 = String::Handle(String::New(" \xc3\xa7 ")); 1980 const String& str1 = String::Handle(String::New(" \xc3\xa7 "));
1960 String::CodePointIterator it1(str1); 1981 String::CodePointIterator it1(str1);
1961 EXPECT(it1.Next()); 1982 EXPECT(it1.Next());
1962 EXPECT_EQ(' ', it1.Current()); 1983 EXPECT_EQ(' ', it1.Current());
1963 EXPECT(it1.Next()); 1984 EXPECT(it1.Next());
(...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 EXPECT_VALID(h_result); 4496 EXPECT_VALID(h_result);
4476 Integer& result = Integer::Handle(); 4497 Integer& result = Integer::Handle();
4477 result ^= Api::UnwrapHandle(h_result); 4498 result ^= Api::UnwrapHandle(h_result);
4478 String& foo = String::Handle(String::New("foo")); 4499 String& foo = String::Handle(String::New("foo"));
4479 Integer& expected = Integer::Handle(); 4500 Integer& expected = Integer::Handle();
4480 expected ^= foo.HashCode(); 4501 expected ^= foo.HashCode();
4481 EXPECT(result.IsIdenticalTo(expected)); 4502 EXPECT(result.IsIdenticalTo(expected));
4482 } 4503 }
4483 4504
4484 } // namespace dart 4505 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698