| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_GN_TEST_WITH_SCOPE_H_ | 5 #ifndef TOOLS_GN_TEST_WITH_SCOPE_H_ |
| 6 #define TOOLS_GN_TEST_WITH_SCOPE_H_ | 6 #define TOOLS_GN_TEST_WITH_SCOPE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(TestWithScope); | 54 DISALLOW_COPY_AND_ASSIGN(TestWithScope); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // Helper class to treat some string input as a file. | 57 // Helper class to treat some string input as a file. |
| 58 // | 58 // |
| 59 // Instantiate it with the contents you want, be sure to check for error, and | 59 // Instantiate it with the contents you want, be sure to check for error, and |
| 60 // then you can execute the ParseNode or whatever. | 60 // then you can execute the ParseNode or whatever. |
| 61 class TestParseInput { | 61 class TestParseInput { |
| 62 public: | 62 public: |
| 63 TestParseInput(const std::string& input); | 63 explicit TestParseInput(const std::string& input); |
| 64 ~TestParseInput(); | 64 ~TestParseInput(); |
| 65 | 65 |
| 66 // Indicates whether and what error occurred during tokenizing and parsing. | 66 // Indicates whether and what error occurred during tokenizing and parsing. |
| 67 bool has_error() const { return parse_err_.has_error(); } | 67 bool has_error() const { return parse_err_.has_error(); } |
| 68 const Err& parse_err() const { return parse_err_; } | 68 const Err& parse_err() const { return parse_err_; } |
| 69 | 69 |
| 70 const InputFile& input_file() const { return input_file_; } | 70 const InputFile& input_file() const { return input_file_; } |
| 71 const std::vector<Token>& tokens() const { return tokens_; } | 71 const std::vector<Token>& tokens() const { return tokens_; } |
| 72 const ParseNode* parsed() const { return parsed_.get(); } | 72 const ParseNode* parsed() const { return parsed_.get(); } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 InputFile input_file_; | 75 InputFile input_file_; |
| 76 | 76 |
| 77 std::vector<Token> tokens_; | 77 std::vector<Token> tokens_; |
| 78 scoped_ptr<ParseNode> parsed_; | 78 scoped_ptr<ParseNode> parsed_; |
| 79 | 79 |
| 80 Err parse_err_; | 80 Err parse_err_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(TestParseInput); | 82 DISALLOW_COPY_AND_ASSIGN(TestParseInput); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ | 85 #endif // TOOLS_GN_TEST_WITH_SCOPE_H_ |
| OLD | NEW |