<commit_before>#!/usr/bin/env ruby

require_relative '../cyberdojo_test_base'

class OutputRStopIfNotTests < CyberDojoTestBase

  test 'ran but failed 42 is red' do
    output =
    [
      'Error: 42 == answer() is not TRUE',
      'Execution halted'
    ].join("\n")
    assert_equal :red, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'ran but failed 43 is red' do
    output =
    [
      'Error: 43 == answer() is not TRUE',
      'Execution halted'
    ].join("\n")
    assert_equal :red, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'syntax error is amber' do
    output =
    [
      ":Error: object 'sss' not found",
      'Execution halted'
    ].join("\n")
    assert_equal :amber, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'sourced filename does not exist is amber' do
    output =
    [
      'Error in file(filename, "r", encoding = encoding) : ',
      '  cannot open the connection',
      'Calls: source -> file',
      'In addition: Warning message:',
      'In file(filename, "r", encoding = encoding) :',
      "  cannot open file 'shiker.R': No such file or directory",
      'Execution halted',<commit_msg>working on R tests for stop instead of stopifnot<commit_after>#!/usr/bin/env ruby

require_relative '../cyberdojo_test_base'

class OutputRStopIfNotTests < CyberDojoTestBase

  test 'ran but failed 42 is red' do
    output =
    [
      'Error: 42 == answer() is not TRUE',
      'Execution halted'
    ].join("\n")
    assert_equal :red, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'ran but failed 43 is red' do
    output =
    [
      'Error: 43 == answer() is not TRUE',
      'Execution halted'
    ].join("\n")
    assert_equal :red, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  #test 'stop rather than stopifnot is red' do
  #  output =
  #  [
  #    'Error: 74 has not been replaced by FizzBuzz',
  #    'Execution halted'
  #  ].join("\n")
  #  assert_equal :red, colour_of(output)
  #end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'syntax error is amber' do
    output =
    [
      "Error: object 'sss' not found",
      'Execution halted'
    ].join("\n")
    assert_equal :amber, colour_of(output)
  end

  #- - - - - - - - - - - - - - - - - - - - - - - -

  test 'sourced filename does not exist is amber' do
    output =
    [
      'Error in file(filename, "r", encoding = encoding) : ',
      '  cannot open the connection',
      'Calls: source -> file',
      'In addition: Warning message:',
      'In file(filename, "r", encoding = encoding) :',
      "  cannot open file 'shiker.R': No such file or directory",
      'Execution halted',
{'fraction_non_alphanumeric': 0.1713161659513591, 'fraction_numerical': 0.006437768240343348, 'mean_word_length': 1.718172983479106, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '117795', 'n_tokens_mistral': 1020, 'n_tokens_neox': 964, 'n_words': 261}