| OLD | NEW |
| 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/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 Script& script = Script::Handle(Script::New(url, | 214 Script& script = Script::Handle(Script::New(url, |
| 215 source, | 215 source, |
| 216 RawScript::kScriptTag)); | 216 RawScript::kScriptTag)); |
| 217 script.Tokenize(String::Handle(String::New(""))); | 217 script.Tokenize(String::Handle(String::New(""))); |
| 218 const TokenStream& tokens = TokenStream::Handle(script.tokens()); | 218 const TokenStream& tokens = TokenStream::Handle(script.tokens()); |
| 219 const String& gen_source = String::Handle(tokens.GenerateSource()); | 219 const String& gen_source = String::Handle(tokens.GenerateSource()); |
| 220 EXPECT_STREQ(source.ToCString(), gen_source.ToCString()); | 220 EXPECT_STREQ(source.ToCString(), gen_source.ToCString()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 TEST_CASE(Class_ComputeEndTokenPos) { |
| 225 const char* kScript = |
| 226 "\n" |
| 227 "class A {\n" |
| 228 " /**\n" |
| 229 " * Description of foo().\n" |
| 230 " */\n" |
| 231 " foo(a) { return '''\"}'''; }\n" |
| 232 " // }\n" |
| 233 " var bar = '\\'}';\n" |
| 234 " var baz = \"${foo('}')}\";\n" |
| 235 "}\n"; |
| 236 Dart_Handle lib_h = TestCase::LoadTestScript(kScript, NULL); |
| 237 EXPECT_VALID(lib_h); |
| 238 Library& lib = Library::Handle(); |
| 239 lib ^= Api::UnwrapHandle(lib_h); |
| 240 EXPECT(!lib.IsNull()); |
| 241 const Class& cls = Class::Handle( |
| 242 lib.LookupClass(String::Handle(String::New("A")))); |
| 243 EXPECT(!cls.IsNull()); |
| 244 const intptr_t end_token_pos = cls.ComputeEndTokenPos(); |
| 245 const Script& scr = Script::Handle(cls.script()); |
| 246 intptr_t line; |
| 247 intptr_t col; |
| 248 scr.GetTokenLocation(end_token_pos, &line, &col); |
| 249 EXPECT(line == 10 && col == 1); |
| 250 } |
| 251 |
| 252 |
| 224 TEST_CASE(InstanceClass) { | 253 TEST_CASE(InstanceClass) { |
| 225 // Allocate the class first. | 254 // Allocate the class first. |
| 226 String& class_name = String::Handle(Symbols::New("EmptyClass")); | 255 String& class_name = String::Handle(Symbols::New("EmptyClass")); |
| 227 Script& script = Script::Handle(); | 256 Script& script = Script::Handle(); |
| 228 const Class& empty_class = | 257 const Class& empty_class = |
| 229 Class::Handle(CreateDummyClass(class_name, script)); | 258 Class::Handle(CreateDummyClass(class_name, script)); |
| 230 | 259 |
| 231 // EmptyClass has no fields and no functions. | 260 // EmptyClass has no fields and no functions. |
| 232 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); | 261 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); |
| 233 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); | 262 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); |
| (...skipping 3871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4105 EXPECT_VALID(h_result); | 4134 EXPECT_VALID(h_result); |
| 4106 Integer& result = Integer::Handle(); | 4135 Integer& result = Integer::Handle(); |
| 4107 result ^= Api::UnwrapHandle(h_result); | 4136 result ^= Api::UnwrapHandle(h_result); |
| 4108 String& foo = String::Handle(String::New("foo")); | 4137 String& foo = String::Handle(String::New("foo")); |
| 4109 Integer& expected = Integer::Handle(); | 4138 Integer& expected = Integer::Handle(); |
| 4110 expected ^= foo.HashCode(); | 4139 expected ^= foo.HashCode(); |
| 4111 EXPECT(result.IsIdenticalTo(expected)); | 4140 EXPECT(result.IsIdenticalTo(expected)); |
| 4112 } | 4141 } |
| 4113 | 4142 |
| 4114 } // namespace dart | 4143 } // namespace dart |
| OLD | NEW |