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

Side by Side Diff: test/cctest/test-flags.cc

Issue 23890027: Add flags to force or prevent setting of isolate.is_memory_constrained. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix dumb typo in ASSERT and add tests to test-flags.cc Created 7 years, 3 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 | « src/isolate.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 49
50 TEST(Flags1) { 50 TEST(Flags1) {
51 FlagList::PrintHelp(); 51 FlagList::PrintHelp();
52 } 52 }
53 53
54 54
55 TEST(Flags2) { 55 TEST(Flags2) {
56 SetFlagsToDefault(); 56 SetFlagsToDefault();
57 int argc = 7; 57 int argc = 8;
58 const char* argv[] = { "Test2", "-notesting-bool-flag", "notaflag", 58 const char* argv[] = { "Test2", "-notesting-bool-flag",
59 "--notesting-maybe-bool-flag", "notaflag",
59 "--testing_int_flag=77", "-testing_float_flag=.25", 60 "--testing_int_flag=77", "-testing_float_flag=.25",
60 "--testing_string_flag", "no way!" }; 61 "--testing_string_flag", "no way!" };
61 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, 62 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
62 const_cast<char **>(argv), 63 const_cast<char **>(argv),
63 false)); 64 false));
64 CHECK_EQ(7, argc); 65 CHECK_EQ(8, argc);
65 CHECK(!FLAG_testing_bool_flag); 66 CHECK(!FLAG_testing_bool_flag);
67 CHECK(FLAG_testing_maybe_bool_flag.has_value);
68 CHECK(!FLAG_testing_maybe_bool_flag.value);
66 CHECK_EQ(77, FLAG_testing_int_flag); 69 CHECK_EQ(77, FLAG_testing_int_flag);
67 CHECK_EQ(.25, FLAG_testing_float_flag); 70 CHECK_EQ(.25, FLAG_testing_float_flag);
68 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!")); 71 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!"));
69 } 72 }
70 73
71 74
72 TEST(Flags2b) { 75 TEST(Flags2b) {
73 SetFlagsToDefault(); 76 SetFlagsToDefault();
74 const char* str = 77 const char* str =
75 " -notesting-bool-flag notaflag --testing_int_flag=77 " 78 " -notesting-bool-flag notaflag --testing_int_flag=77 "
79 "-notesting-maybe-bool-flag "
76 "-testing_float_flag=.25 " 80 "-testing_float_flag=.25 "
77 "--testing_string_flag no_way! "; 81 "--testing_string_flag no_way! ";
78 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); 82 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
79 CHECK(!FLAG_testing_bool_flag); 83 CHECK(!FLAG_testing_bool_flag);
84 CHECK(FLAG_testing_maybe_bool_flag.has_value);
85 CHECK(!FLAG_testing_maybe_bool_flag.value);
80 CHECK_EQ(77, FLAG_testing_int_flag); 86 CHECK_EQ(77, FLAG_testing_int_flag);
81 CHECK_EQ(.25, FLAG_testing_float_flag); 87 CHECK_EQ(.25, FLAG_testing_float_flag);
82 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!")); 88 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!"));
83 } 89 }
84 90
85 91
86 TEST(Flags3) { 92 TEST(Flags3) {
87 SetFlagsToDefault(); 93 SetFlagsToDefault();
88 int argc = 8; 94 int argc = 9;
89 const char* argv[] = 95 const char* argv[] =
90 { "Test3", "--testing_bool_flag", "notaflag", 96 { "Test3", "--testing_bool_flag", "--testing-maybe-bool-flag", "notaflag",
91 "--testing_int_flag", "-666", 97 "--testing_int_flag", "-666",
92 "--testing_float_flag", "-12E10", "-testing-string-flag=foo-bar" }; 98 "--testing_float_flag", "-12E10", "-testing-string-flag=foo-bar" };
93 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, 99 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
94 const_cast<char **>(argv), 100 const_cast<char **>(argv),
95 true)); 101 true));
96 CHECK_EQ(2, argc); 102 CHECK_EQ(2, argc);
97 CHECK(FLAG_testing_bool_flag); 103 CHECK(FLAG_testing_bool_flag);
104 CHECK(FLAG_testing_maybe_bool_flag.has_value);
105 CHECK(FLAG_testing_maybe_bool_flag.value);
98 CHECK_EQ(-666, FLAG_testing_int_flag); 106 CHECK_EQ(-666, FLAG_testing_int_flag);
99 CHECK_EQ(-12E10, FLAG_testing_float_flag); 107 CHECK_EQ(-12E10, FLAG_testing_float_flag);
100 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); 108 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
101 } 109 }
102 110
103 111
104 TEST(Flags3b) { 112 TEST(Flags3b) {
105 SetFlagsToDefault(); 113 SetFlagsToDefault();
106 const char* str = 114 const char* str =
107 "--testing_bool_flag notaflag --testing_int_flag -666 " 115 "--testing_bool_flag --testing-maybe-bool-flag notaflag "
116 "--testing_int_flag -666 "
108 "--testing_float_flag -12E10 " 117 "--testing_float_flag -12E10 "
109 "-testing-string-flag=foo-bar"; 118 "-testing-string-flag=foo-bar";
110 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); 119 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
111 CHECK(FLAG_testing_bool_flag); 120 CHECK(FLAG_testing_bool_flag);
121 CHECK(FLAG_testing_maybe_bool_flag.has_value);
122 CHECK(FLAG_testing_maybe_bool_flag.value);
112 CHECK_EQ(-666, FLAG_testing_int_flag); 123 CHECK_EQ(-666, FLAG_testing_int_flag);
113 CHECK_EQ(-12E10, FLAG_testing_float_flag); 124 CHECK_EQ(-12E10, FLAG_testing_float_flag);
114 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar")); 125 CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
115 } 126 }
116 127
117 128
118 TEST(Flags4) { 129 TEST(Flags4) {
119 SetFlagsToDefault(); 130 SetFlagsToDefault();
120 int argc = 3; 131 int argc = 3;
121 const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" }; 132 const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" };
122 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc, 133 CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
123 const_cast<char **>(argv), 134 const_cast<char **>(argv),
124 true)); 135 true));
125 CHECK_EQ(2, argc); 136 CHECK_EQ(2, argc);
137 CHECK(!FLAG_testing_maybe_bool_flag.has_value);
126 } 138 }
127 139
128 140
129 TEST(Flags4b) { 141 TEST(Flags4b) {
130 SetFlagsToDefault(); 142 SetFlagsToDefault();
131 const char* str = "--testing_bool_flag --foo"; 143 const char* str = "--testing_bool_flag --foo";
132 CHECK_EQ(2, FlagList::SetFlagsFromString(str, StrLength(str))); 144 CHECK_EQ(2, FlagList::SetFlagsFromString(str, StrLength(str)));
145 CHECK(!FLAG_testing_maybe_bool_flag.has_value);
133 } 146 }
134 147
135 148
136 TEST(Flags5) { 149 TEST(Flags5) {
137 SetFlagsToDefault(); 150 SetFlagsToDefault();
138 int argc = 2; 151 int argc = 2;
139 const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" }; 152 const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" };
140 CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc, 153 CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc,
141 const_cast<char **>(argv), 154 const_cast<char **>(argv),
142 true)); 155 true));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // if the list of arguments ends unexpectedly. 251 // if the list of arguments ends unexpectedly.
239 SetFlagsToDefault(); 252 SetFlagsToDefault();
240 int argc = 3; 253 int argc = 3;
241 const char* argv[] = { "", "--crankshaft", "--expose-debug-as" }; 254 const char* argv[] = { "", "--crankshaft", "--expose-debug-as" };
242 CHECK_EQ(2, FlagList::SetFlagsFromCommandLine(&argc, 255 CHECK_EQ(2, FlagList::SetFlagsFromCommandLine(&argc,
243 const_cast<char **>(argv), 256 const_cast<char **>(argv),
244 true)); 257 true));
245 CHECK_NE(NULL, argv[1]); 258 CHECK_NE(NULL, argv[1]);
246 CHECK_EQ(argc, 2); 259 CHECK_EQ(argc, 2);
247 } 260 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698