| 267 | } |
| 268 | |
| 269 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 270 | chaiscript::ChaiScript chai; |
| 271 | |
| 272 | chai.eval( R"chaiscript( |
| 273 | def assert_equal(x, y) |
| 274 | { |
| 275 | if (x == y) |
| 276 | { |
| 277 | // Passes |
| 278 | } else { |
| 279 | // Fails |
| 280 | print("assert_equal failure: got '" + to_string(y) + "' expected '" + to_string(x) + "'"); |
| 281 | // exit(-1); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | def assert_false(f) |
| 286 | { |
| 287 | if (f) |
| 288 | { |
| 289 | print("assert_false failure"); |
| 290 | // exit(-1); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | def assert_true(f) |
| 295 | { |
| 296 | if (!f) |
| 297 | { |
| 298 | print("assert_true failure"); |
| 299 | // exit(-1); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | def assert_not_equal(x, y) |
| 304 | { |
| 305 | if (!(x == y)) |
| 306 | { |
| 307 | // Passes |
| 308 | } else { |
| 309 | // Fails |
| 310 | print("assert_not_equal failure: got " + to_string(y) + " which was not expected."); |
| 311 | // exit(-1); |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | def assert_throws(desc, x) |
| 316 | { |
| 317 | if (throws_exception(x)) |
| 318 | { |
| 319 | // Passes |
| 320 | } else { |
| 321 | // Fails |
| 322 | print("assert_throws failure, function did not throw exception: " + to_string(desc)); |
| 323 | // exit(-1); |
| 324 | } |
| 325 | })chaiscript"); |
| 326 | |