How to use the js-slang/dist/types.ErrorType.RUNTIME function in js-slang

To help you get started, we’ve selected a few js-slang examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github source-academy / cadet-frontend / src / components / workspace / side-content / __tests__ / Autograder.tsx View on Github external
import { mount, shallow } from 'enzyme';
import * as React from 'react';

import { ErrorSeverity, ErrorType, SourceError } from 'js-slang/dist/types';
import {
  AutogradingResult,
  ITestcase,
  TestcaseTypes
} from '../../../../components/assessment/assessmentShape';
import Autograder, { AutograderProps } from '../Autograder';

const mockErrors: SourceError[] = [
  {
    type: ErrorType.RUNTIME,
    severity: ErrorSeverity.ERROR,
    location: { start: { line: 3, column: 11 }, end: { line: 3, column: 11 } },
    explain() {
      return `Name a not declared.`;
    },
    elaborate() {
      return `Name a not declared.`;
    }
  }
];

// The five testcases have statuses: correct, (none), correct, incorrect and error
const mockPublicTestcases: ITestcase[] = [
  { program: `"string";`, score: 0, answer: `"string"`, result: `string` },
  { program: `fibonacci(2);`, score: 1, answer: `2` },
  { program: `fibonacci(3);`, score: 1, answer: `2`, result: 2 },