OLD | NEW |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 | 153 |
154 TEST(Flags6) { | 154 TEST(Flags6) { |
155 SetFlagsToDefault(); | 155 SetFlagsToDefault(); |
156 int argc = 4; | 156 int argc = 4; |
157 const char* argv[] = { "Test5", "--testing-int-flag", "0", | 157 const char* argv[] = { "Test5", "--testing-int-flag", "0", |
158 "--testing_float_flag" }; | 158 "--testing_float_flag" }; |
159 CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc, | 159 CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc, |
160 const_cast<char **>(argv), | 160 const_cast<char **>(argv), |
161 true)); | 161 true)); |
162 CHECK_EQ(4, argc); | 162 CHECK_EQ(2, argc); |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 TEST(Flags6b) { | 166 TEST(Flags6b) { |
167 SetFlagsToDefault(); | 167 SetFlagsToDefault(); |
168 const char* str = " --testing-int-flag 0 --testing_float_flag "; | 168 const char* str = " --testing-int-flag 0 --testing_float_flag "; |
169 CHECK_EQ(3, FlagList::SetFlagsFromString(str, StrLength(str))); | 169 CHECK_EQ(3, FlagList::SetFlagsFromString(str, StrLength(str))); |
170 } | 170 } |
171 | 171 |
172 | 172 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 | 226 |
227 TEST(FlagsJSArguments4) { | 227 TEST(FlagsJSArguments4) { |
228 SetFlagsToDefault(); | 228 SetFlagsToDefault(); |
229 const char* str = "--testing-int-flag 42 --"; | 229 const char* str = "--testing-int-flag 42 --"; |
230 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); | 230 CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str))); |
231 CHECK_EQ(42, FLAG_testing_int_flag); | 231 CHECK_EQ(42, FLAG_testing_int_flag); |
232 CHECK_EQ(0, FLAG_js_arguments.argc()); | 232 CHECK_EQ(0, FLAG_js_arguments.argc()); |
233 } | 233 } |
234 | 234 |
| 235 |
| 236 TEST(FlagsRemoveIncomplete) { |
| 237 // Test that processed command line arguments are removed, even |
| 238 // if the list of arguments ends unexpectedly. |
| 239 SetFlagsToDefault(); |
| 240 int argc = 3; |
| 241 const char* argv[] = { "", "--crankshaft", "--expose-debug-as" }; |
| 242 CHECK_EQ(2, FlagList::SetFlagsFromCommandLine(&argc, |
| 243 const_cast<char **>(argv), |
| 244 true)); |
| 245 CHECK_NE(NULL, argv[1]); |
| 246 CHECK_EQ(argc, 2); |
| 247 } |
OLD | NEW |