| 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 "vm/assembler.h" | 5 #include "vm/assembler.h" |
| 6 #include "vm/bigint_operations.h" | 6 #include "vm/bigint_operations.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4051 | 4051 |
| 4052 // Simple map. | 4052 // Simple map. |
| 4053 // | 4053 // |
| 4054 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} | 4054 // TODO(turnidge): Consider showing something like: {1: 2, 2: 'otter'} |
| 4055 result = Dart_GetField(lib, NewString("simple_map")); | 4055 result = Dart_GetField(lib, NewString("simple_map")); |
| 4056 EXPECT_VALID(result); | 4056 EXPECT_VALID(result); |
| 4057 obj ^= Api::UnwrapHandle(result); | 4057 obj ^= Api::UnwrapHandle(result); |
| 4058 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); | 4058 EXPECT_STREQ("Instance of '_LinkedHashMap'", obj.ToUserCString()); |
| 4059 } | 4059 } |
| 4060 | 4060 |
| 4061 |
| 4062 class JSONTypeVerifier : public ObjectVisitor { |
| 4063 public: |
| 4064 JSONTypeVerifier() : ObjectVisitor(Isolate::Current()) {} |
| 4065 virtual ~JSONTypeVerifier() { } |
| 4066 virtual void VisitObject(RawObject* obj) { |
| 4067 // Free-list elements cannot even be wrapped in handles. |
| 4068 if (obj->IsFreeListElement()) { |
| 4069 return; |
| 4070 } |
| 4071 Object& handle = Object::Handle(obj); |
| 4072 // Skip some common simple objects to run in reasonable time. |
| 4073 if (handle.IsString() || |
| 4074 handle.IsArray() || |
| 4075 handle.IsLiteralToken()) { |
| 4076 return; |
| 4077 } |
| 4078 JSONStream js; |
| 4079 handle.PrintToJSONStream(&js, false); |
| 4080 // TODO(koda): When all objects include a "type" field, expect that here. |
| 4081 } |
| 4082 }; |
| 4083 |
| 4084 |
| 4085 TEST_CASE(PrintToJSONStream) { |
| 4086 Heap* heap = Isolate::Current()->heap(); |
| 4087 heap->CollectAllGarbage(); |
| 4088 JSONTypeVerifier verifier; |
| 4089 heap->IterateObjects(&verifier); |
| 4090 } |
| 4091 |
| 4061 } // namespace dart | 4092 } // namespace dart |
| OLD | NEW |