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

Side by Side Diff: vm/snapshot_test.cc

Issue 10765017: Add quotes around strings when generating source from the token stream. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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
« vm/object.cc ('K') | « vm/object.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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.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_api_message.h" 10 #include "vm/dart_api_message.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 EXPECT(root->value.as_byte_array.values == NULL); 713 EXPECT(root->value.as_byte_array.values == NULL);
714 CheckEncodeDecodeMessage(root); 714 CheckEncodeDecodeMessage(root);
715 } 715 }
716 716
717 717
718 TEST_CASE(SerializeScript) { 718 TEST_CASE(SerializeScript) {
719 const char* kScriptChars = 719 const char* kScriptChars =
720 "class A {\n" 720 "class A {\n"
721 " static bar() { return 42; }\n" 721 " static bar() { return 42; }\n"
722 " static fly() { return 5; }\n" 722 " static fly() { return 5; }\n"
723 " static s1() { return 'this is a string in the source'; }\n"
724 " static s2() { return 'this is a \"string\" in the source'; }\n"
725 " static s3() { return 'this is a \\\'string\\\' in \"the\" source'; }\n"
726 " static s4() { return 'this \"is\" a \"string\" in \"the\" source'; }\n"
723 "}\n"; 727 "}\n";
724 728
725 String& url = String::Handle(String::New("dart-test:SerializeScript")); 729 String& url = String::Handle(String::New("dart-test:SerializeScript"));
726 String& source = String::Handle(String::New(kScriptChars)); 730 String& source = String::Handle(String::New(kScriptChars));
727 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); 731 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource));
728 const String& lib_url = String::Handle(String::NewSymbol("TestLib")); 732 const String& lib_url = String::Handle(String::NewSymbol("TestLib"));
729 Library& lib = Library::Handle(Library::New(lib_url)); 733 Library& lib = Library::Handle(Library::New(lib_url));
730 lib.Register(); 734 lib.Register();
731 EXPECT(CompilerTest::TestCompileScript(lib, script)); 735 EXPECT(CompilerTest::TestCompileScript(lib, script));
732 736
(...skipping 24 matching lines...) Expand all
757 for (intptr_t i = 0; i < expected_tokens.Length(); i++) { 761 for (intptr_t i = 0; i < expected_tokens.Length(); i++) {
758 EXPECT_EQ(expected_tokens.KindAt(i), serialized_tokens.KindAt(i)); 762 EXPECT_EQ(expected_tokens.KindAt(i), serialized_tokens.KindAt(i));
759 expected_literal ^= expected_tokens.LiteralAt(i); 763 expected_literal ^= expected_tokens.LiteralAt(i);
760 actual_literal ^= serialized_tokens.LiteralAt(i); 764 actual_literal ^= serialized_tokens.LiteralAt(i);
761 EXPECT(expected_literal.Equals(actual_literal)); 765 EXPECT(expected_literal.Equals(actual_literal));
762 } 766 }
763 // Check if we are able to generate the source from the token stream. 767 // Check if we are able to generate the source from the token stream.
764 // Rescan this source and compare the token stream to see if they are 768 // Rescan this source and compare the token stream to see if they are
765 // the same. 769 // the same.
766 str ^= serialized_tokens.GenerateSource(); 770 str ^= serialized_tokens.GenerateSource();
771 OS::Print("%s", str.ToCString());
cshapiro 2012/07/10 19:03:27 Is this supposed to be here?
siva 2012/07/10 22:59:10 Removed this line, it was there for verifying what
767 const String& dummy_key = String::Handle(String::New("")); 772 const String& dummy_key = String::Handle(String::New(""));
768 Scanner scanner(str, dummy_key); 773 Scanner scanner(str, dummy_key);
769 const TokenStream& reconstructed_tokens = 774 const TokenStream& reconstructed_tokens =
770 TokenStream::Handle(TokenStream::New(scanner.GetStream())); 775 TokenStream::Handle(TokenStream::New(scanner.GetStream()));
771 for (intptr_t i = 0; i < expected_tokens.Length(); i++) { 776 for (intptr_t i = 0; i < expected_tokens.Length(); i++) {
772 EXPECT_EQ(expected_tokens.KindAt(i), serialized_tokens.KindAt(i)); 777 EXPECT_EQ(expected_tokens.KindAt(i), serialized_tokens.KindAt(i));
773 expected_literal ^= expected_tokens.LiteralAt(i); 778 expected_literal ^= expected_tokens.LiteralAt(i);
774 actual_literal ^= reconstructed_tokens.LiteralAt(i); 779 actual_literal ^= reconstructed_tokens.LiteralAt(i);
775 EXPECT(expected_literal.Equals(actual_literal)); 780 EXPECT(expected_literal.Equals(actual_literal));
776 } 781 }
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 EXPECT(Dart_ErrorHasException(result)); 1543 EXPECT(Dart_ErrorHasException(result));
1539 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n", 1544 EXPECT_SUBSTRING("Exception: nulltruefalse1234563.14[]100123456789\n",
1540 Dart_GetError(result)); 1545 Dart_GetError(result));
1541 1546
1542 Dart_ExitScope(); 1547 Dart_ExitScope();
1543 } 1548 }
1544 1549
1545 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 1550 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
1546 1551
1547 } // namespace dart 1552 } // namespace dart
OLDNEW
« vm/object.cc ('K') | « vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698