OLD | NEW |
1 #include <AdblockPlus.h> | 1 #include <AdblockPlus.h> |
2 #include <fstream> | 2 #include <fstream> |
3 #include <gtest/gtest.h> | 3 #include <gtest/gtest.h> |
4 #include <sstream> | 4 #include <sstream> |
5 | 5 |
6 class ThrowingFileReader : public AdblockPlus::FileReader | 6 class ThrowingFileReader : public AdblockPlus::FileReader |
7 { | 7 { |
8 public: | 8 public: |
9 std::auto_ptr<std::istream> Read(const std::string& path) const | 9 std::auto_ptr<std::istream> Read(const std::string& path) const |
10 { | 10 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 TEST(JsEngineTest, LoadBadStreamFails) | 67 TEST(JsEngineTest, LoadBadStreamFails) |
68 { | 68 { |
69 BadFileReader fileReader; | 69 BadFileReader fileReader; |
70 ThrowingErrorCallback errorCallback; | 70 ThrowingErrorCallback errorCallback; |
71 AdblockPlus::JsEngine jsEngine(&fileReader, &errorCallback); | 71 AdblockPlus::JsEngine jsEngine(&fileReader, &errorCallback); |
72 ASSERT_ANY_THROW(jsEngine.Load("hello.js")); | 72 ASSERT_ANY_THROW(jsEngine.Load("hello.js")); |
73 } | 73 } |
74 | 74 |
75 TEST(JsEngineTest, JsExceptionIsThrown) | 75 TEST(JsEngineTest, RuntimeExceptionIsThrown) |
76 { | 76 { |
77 ThrowingFileReader fileReader; | 77 ThrowingFileReader fileReader; |
78 ThrowingErrorCallback errorCallback; | 78 ThrowingErrorCallback errorCallback; |
79 AdblockPlus::JsEngine jsEngine(&fileReader, &errorCallback); | 79 AdblockPlus::JsEngine jsEngine(&fileReader, &errorCallback); |
80 ASSERT_THROW(jsEngine.Evaluate("doesnotexist()"), AdblockPlus::JsError); | 80 ASSERT_THROW(jsEngine.Evaluate("doesnotexist()"), AdblockPlus::JsError); |
81 } | 81 } |
| 82 |
| 83 TEST(JsEngineTest, CompileTimeExceptionIsThrown) |
| 84 { |
| 85 ThrowingFileReader fileReader; |
| 86 ThrowingErrorCallback errorCallback; |
| 87 AdblockPlus::JsEngine jsEngine(&fileReader, &errorCallback); |
| 88 ASSERT_THROW(jsEngine.Evaluate("'foo'bar'"), AdblockPlus::JsError); |
| 89 } |
OLD | NEW |