Skip to main content
Install Relativities before running the examples. The installation includes the rslc compiler. A scenario is an RSL file that gives a rater one set of inputs, the values to print, and the values you expect. rslc eval rates the inputs and compares each expected value with the computed one. The example is the worked example of Write your first rater. A $250,000 dwelling in protection class 5, with scheduled items worth $1,200 and $800, has a $1,028 premium. Save the two files of that rater, or run rslc examples get dwelling.
dwelling/rater.rsl
dwelling/tables/BaseRate.csv

Write the scenario

Save this file as dwelling/worked-example.rsl, in the same folder as rater.rsl:
dwelling/worked-example.rsl
The file imports the rater and holds one Scenario section with three parts. instances gives the inputs, evaluate lists the values to print, and assert states the expected values.

Run the scenario

  • The first line gives the result of the whole scenario.
  • The targets line gives each listed value, sorted by name. exact is the exact decimal, and value is the same number as a float.
  • Each assertion gets one line, in the order of the file. The name after @ is the instance that the assertion starts with.

Name the inputs

Each entry of instances creates one record of the rater and gives it a name:
  • The entry starts with the record, then a name of your choice: Dwelling home.
  • input = value sets one input of that record. Write a number, true or false, a date such as 2026-01-01, or an enum member such as @Peril.fire.
  • parent: policy places the record inside the instance named policy. So home becomes the dwelling of the policy.
  • Each Item with parent: policy joins the items list of the policy, in the order of the file.
  • A record that holds only other records, such as Policy here, still needs its entry.
The rater applies the same input rules to a scenario as to a request. Refusals lists the codes.

List the values to print

targets names each value as instance.name:
  • A target is a calculation or an input of the record.
  • A calculation with a key, such as peril_premium, takes one member in brackets.
  • evaluate is optional. A scenario with instances and evaluate alone prints the values, which helps while you build the example.

State the expected values

Each line of assert is a comparison that must hold:
  • = compares exact values. So 1028 equals 1028.00, and 1027.5 differs from 1028.
  • An assertion reads any value of an instance, listed in targets or left out of it.
  • Other comparisons work too, such as policy.premium > 1000 and policy.premium in [1000, 1100].
  • assert is optional.

Read a wrong expectation

This copy of the scenario expects a premium of 1,030:
dwelling/wrong-premium.rsl
The failed = assertion prints the computed value and the expected value. A failed comparison of another kind prints FAIL assertion: and the instance name alone. Count the lines to find the assertion: the third line belongs to the third assertion.

Read an incomplete scenario

This copy leaves out protection_class:
dwelling/incomplete.rsl
The rater refuses the inputs, as it refuses a request, and the message names the code and the path. A value that breaks a rule prints the code of that rule. Protection class 12 prints PROTECTION-CLASS and the message of the rule.

Compute the values that the inputs reach

Add --partial to compute what the given inputs allow:
  • targets holds the values that the inputs reach. Here the item charge needs only the items.
  • blocked lists the missing input and each value that waits for it.
  • An assertion over a blocked value fails.
  • With every input present, --partial prints the same lines as the plain command.

Read the exit code

Add --json to print one JSON value for a program. Its status is passed, failed or incomplete. Its targets holds the computed values, and each entry of assertions holds passed, the computed value as left and the expected value as right.

Rules for a scenario file

  • Keep the scenario in the folder of the rater it imports. The rater reads its tables from that folder.
  • Write one Scenario section in a file. rslc eval runs the first one.
  • Check each input name against the rater. rslc eval skips a name that the record lacks.
  • A target or an assertion that names an unknown value stops the run with E-UNRESOLVED and the line.
  • rslc check and rslc fmt take a scenario file. rslc fmt writes the layout this page shows.
  • rslc export leaves the scenario out of the bundle.