<commit_before>require 'spec_helper'
require 'support/editor'

RSpec.feature "Compiling to different formats", type: :feature, js: true do
  before do
    visit '/'
    editor.set(code)
  end

  scenario "compiling to assembly" do
    within('.header') { click_on("ASM") }

    within('.output-code') do
      expect(page).to have_content '.text'
      expect(page).to have_content '.file'
      expect(page).to have_content '.section'
      expect(page).to have_content '.p2align'
    end
  end

  scenario "compiling to LLVM IR" do
    within('.header') { click_on("LLVM IR") }

    within('.output-code') do
      expect(page).to have_content 'ModuleID'
      expect(page).to have_content 'target datalayout'
      expect(page).to have_content 'target triple'
    end
  end

  def editor
    Editor.new(page)
  end

  def code
    <<~EOF
    fn main() {
        println!("Hello, world!");
    }
    EOF
  end
end<commit_msg>Add feature spec for MIR output<commit_after>require 'spec_helper'
require 'support/editor'
require 'support/playground_actions'

RSpec.feature "Compiling to different formats", type: :feature, js: true do
  include PlaygroundActions

  before do
    visit '/'
    editor.set(code)
  end

  scenario "compiling to assembly" do
    within('.header') { click_on("ASM") }

    within('.output-code') do
      expect(page).to have_content '.text'
      expect(page).to have_content '.file'
      expect(page).to have_content '.section'
      expect(page).to have_content '.p2align'
    end
  end

  scenario "compiling to LLVM IR" do
    within('.header') { click_on("LLVM IR") }

    within('.output-code') do
      expect(page).to have_content 'ModuleID'
      expect(page).to have_content 'target datalayout'
      expect(page).to have_content 'target triple'
    end
  end

  scenario "compiling to MIR" do
    within('.header') do
      choose_styled("Nightly")
      click_on("MIR")
    end

    within('.output-code') do
      expect(page).to have_content 'StorageLive'
      expect(page).to have_content 'StorageDead'
    end
  end

  def editor
    Editor.new(page)
  end

  def code
    <<~EOF
    fn main() {
        println!("Hello, world!");
    }
    EOF
  end
end
{'fraction_non_alphanumeric': 0.12176283507496592, 'fraction_numerical': 0.0009086778736937755, 'mean_word_length': 2.9391771019677995, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883013', 'n_tokens_mistral': 712, 'n_tokens_neox': 696, 'n_words': 188}