| 565 | } |
| 566 | |
| 567 | Value TestParser::evaluateRandomDotFunction(const std::string& funcCall) { |
| 568 | // Handle random.set_seed(value) and random.randInt32(max) |
| 569 | if (funcCall.starts_with("random.set_seed(") && funcCall.ends_with(")")) { |
| 570 | // Extract parameter from random.set_seed(param) |
| 571 | std::string param = |
| 572 | funcCall.substr(16, funcCall.length() - 17); // Remove "random.set_seed(" and ")" |
| 573 | // Handle variable substitution if needed |
| 574 | replaceVariables(param); |
| 575 | try { |
| 576 | uint64_t seedValue = static_cast<uint64_t>(stoll(param)); |
| 577 | randomEngine.setSeed(seedValue); |
| 578 | return Value(0); // Return dummy value for _ variable |
| 579 | } catch (const std::exception&) { |
| 580 | throw TestException("Invalid seed parameter [" + path + ":" + line + "]."); |
| 581 | } |
| 582 | } |
| 583 | if (funcCall.starts_with("random.randInt32(") && funcCall.ends_with(")")) { |
| 584 | // Extract parameter from random.randInt32(max) |
| 585 | std::string param = |
| 586 | funcCall.substr(17, funcCall.length() - 18); // Remove "random.randInt32(" and ")" |
| 587 | int32_t maxVal = 0; |
| 588 | try { |
| 589 | maxVal = static_cast<int32_t>(stoi(param)); |
| 590 | } catch (const std::exception&) { |
| 591 | throw TestException("Invalid random parameter [" + path + ":" + line + "]."); |
| 592 | } |
| 593 | if (maxVal == 0) { |
| 594 | throw TestException("Random max value must be positive [" + path + ":" + line + "]."); |
| 595 | } |
| 596 | return Value(static_cast<int32_t>(randomEngine.nextRandomInteger(maxVal))); |
| 597 | } |
| 598 | throw TestException("Unknown random function [" + path + ":" + line + "]."); |
| 599 | } |
| 600 | |
| 601 | void TestParser::parseBody() { |
| 602 | bool testFwdOnly = testGroup->testFwdOnly; |
nothing calls this directly
no test coverage detected