<commit_before>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))

describe Buildr::AS3::Compiler::AirMxmlc do

  it 'should not identify itself from source directories' do
    write 'src/main/java/com/example/Test.as', 'package com.example{ class Test {} }'
    define('foo').compile.compiler.should_not eql(:airmxmlc)
  end

  it 'should report the language as :actionscript' do
    define('foo').compile.using(:airmxmlc).language.should eql(:actionscript)
  end

  it 'should set the target directory to target/bin' do
    define 'foo' do
      lambda { compile.using(:airmxmlc) }.should change { compile.target.to_s }.to(File.expand_path('target/bin'))
    end
  end

  it 'should not override existing target directory' do
    define 'foo' do
      compile.into('classes')
      lambda { compile.using(:airmxmlc) }.should_not change { compile.target }
    end
  end

  it 'should not change existing list of sources' do
    define 'foo' do
      compile.from('sources')
      lambda { compile.using(:airmxmlc) }.should_not change { compile.sources }
    end
  end

  after do
    Buildr.options.debug = nil
    ENV.delete "debug"
    ENV.delete "DEBUG"
  end
end



describe "Buildr::AS3::Compiler::airmxmlc compiler options" do

  def compile_task
    @compile_task ||= define('foo').compile.using( :airmxmlc, :flexsdk => FlexSDK.new("4.5.0.20967") )
  end

  def flex_sdk
    compile_task.options.flexsdk
  end

  def output
    compile_task.options.output
  end

  def target
    compile_task.target
  end

  def dependencies
    compile_task.dependencies
  end

  def sources
    compile_task.sources
  end

  def airmxmlc_args
    compiler.send(:compiler_args,dependencies,flex_sdk,output,sources)
  end

  def compiler
    compile_task.instance_eval { @compiler }
  end

  it 'should set warnings option to true by default' do
    compile_task.options.warnings.should be_true
  end

  it 'should set debug option to true by default' do
    compile_task.options.debug.should be_true
  end

  it 'should set debug option to false based on Buildr.options' do
    Buildr.options.debug = false
    compile_task.options.debug.should be_false
  end

  it 'should set debug option to false based on debug environment variable' do
    ENV['debug'] = 'no'
    compile_task.options.debug.should be_false
  end

  it 'should set debug option to false based on DEBUG environment variable' do
    ENV['DEBUG'] = 'no'
    compile_task.options.debug.should be_false
  end

  it 'should use -debug=true argument when debug option is true' do
    compile_task.using(:debug=>true)
    airmxmlc_args.should include('-debug=true')
  end

  it 'should not use -debug=true argument when debug option is false' do
    compile_task.using(:debug=>false)
    airmxmlc_args.should_not include('-debug=true')
  end

  it 'should define CONFIG::debug,true when debug option is true' do
    compile_task.using(:debug=>true)
    airmxmlc_args.should include('-define+=CONFIG::debug,true')
  end

   it 'should define CONFIG::debug,false when debug option is false' do
    compile_task.using(:debug=>false)
    airmxmlc_args.should include('-define+=CONFIG::debug,false')
  end

  it 'should use -warnings=true argument when warnings option is true' do
    compile_task.using(:warnings=>true)
    airmxmlc_args.should_not include('-warnings=false')
  end

  it 'should not use -warnings=true argument when warnings option is false' do
    compile_task.using(:warnings=>false)
    airmxmlc_args.should include('-warnings=false')
  end

  it 'should point to the correct compiler jar' do
    compiler.instance_eval{ compiler_jar }.should eql( flex_sdk.mxmlc_jar )
  end

  it 'should identify itself as an air compiler' do
    compiler.instance_eval{ air }.should eql( true )
  end

  it "should use +configname=air ever" do
    airmxmlc_args.should include('+configname=air')
  end

  it "should use air config file by default" do
    airmxmlc_args.should include(flex_sdk.air_config)
  end

  it "should not use flex config file by default" do
    airmxmlc_args.should_not include(flex_sdk.flex_config)
  end

  it "should not identify itself as a test task when it's not" do
    compiler.send(:is_test,sources,target,dependencies).should eql(false)
  end



end<commit_msg>Compilers refactored. Added tests for compilers.<commit_after>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))

describe Buildr::AS3::Compiler::AirMxmlc do

  it 'should not identify itself from source directories' do
    write 'src/main/java/com/example/Test.as', 'package com.example{ class Test {} }'
    define('foo').compile.compiler.should_not eql(:airmxmlc)
  end

  it 'should report the language as :actionscript' do
    define('foo').compile.using(:airmxmlc).language.should eql(:actionscript)
  end

  it 'should set the target directory to target/bin' do
    define 'foo' do
      lambda { compile.using(:airmxmlc) }.should change { compile.target.to_s }.to(File.expand_path('target/bin'))
    end
  end

  it 'should not override existing target directory' do
    define 'foo' do
      compile.into('classes')
      lambda { compile.using(:airmxmlc) }.should_not change { compile.target }
    end
  end

  it 'should not change existing list of sources' do
    define 'foo' do
      compile.from('sources')
      lambda { compile.using(:airmxmlc) }.should_not change { compile.sources }
    end
  end

  after do
    Buildr.options.debug = nil
    ENV.delete "debug"
    ENV.delete "DEBUG"
  end
end



describe "Buildr::AS3::Compiler::airmxmlc compiler options" do

  def compile_task
    @compile_task ||= define('foo').compile.using( :airmxmlc, :flexsdk => FlexSDK.new("4.5.0.20967") )
  end

  def flex_sdk
    compile_task.options.flexsdk
  end

  def output
    compile_task.options.output
  end

  def target
    compile_task.target
  end

  def dependencies
    compile_task.dependencies
  end

  def sources
    compile_task.sources
  end

  def airmxmlc_args
    compiler.send(:compiler_args,dependencies,flex_sdk,output,sources)
  end

  def compiler
    compile_task.instance_eval { @compiler }
  end

  it 'should set warnings option to true by default' do
    compile_task.options.warnings.should be_true
  end

  it 'should set debug option to true by default' do
    compile_task.options.debug.should be_true
  end

  it 'should set debug option to false based on Buildr.options' do
    Buildr.options.debug = false
    compile_task.options.debug.should be_false
  end

  it 'should set debug option to false based on debug environment variable' do
    ENV['debug'] = 'no'
    compile_task.options.debug.should be_false
  end

  it 'should set debug option to false based on DEBUG environment variable' do
    ENV['DEBUG'] = 'no'
    compile_task.options.debug.should be_false
  end

  it 'should use -debug=true argument when debug option is true' do
    compile_task.using(:debug=>true)
    airmxmlc_args.should include('-debug=true')
  end

  it 'should not use -debug=true argument when debug option is false' do
    compile_task.using(:debug=>false)
    airmxmlc_args.should_not include('-debug=true')
  end

  it 'should define CONFIG::debug,true when debug option is true' do
    compile_task.using(:debug=>true)
    airmxmlc_args.should include('-define+=CONFIG::debug,true')
  end

   it 'should define CONFIG::debug,false when debug option is false' do
    compile_task.using(:debug=>false)
    airmxmlc_args.should include('-define+=CONFIG::debug,false')
  end

  it 'should use -warnings=true argument when warnings option is true' do
    compile_task.using(:warnings=>true)
    airmxmlc_args.should_not include('-warnings=false')
  end

  it 'should not use -warnings=true argument when warnings option is false' do
    compile_task.using(:warnings=>false)
    airmxmlc_args.should include('-warnings=false')
  end

  it 'should point to the correct compiler jar' do
    compiler.instance_eval{ compiler_jar }.should eql( flex_sdk.mxmlc_jar )
  end

  it 'should identify itself as an air compiler' do
    compiler.instance_eval{ air }.should eql( true )
  end

  it "should use +configname=air ever" do
    airmxmlc_args.should include('+configname=air')
  end

  it "should use air config file by default" do
    airmxmlc_args.should include(flex_sdk.air_config)
  end

  it "should not use flex config file by default" do
    airmxmlc_args.should_not include(flex_sdk.flex_config)
  end

  it "should not identify itself as a test task when it's not" do
    compiler.send(:is_test,sources,target,dependencies).should eql(false)
  end

end
{'fraction_non_alphanumeric': 0.09396441446679847, 'fraction_numerical': 0.002325851843237586, 'mean_word_length': 3.7671840354767183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 38}, 'pii_count': 2, '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': '6406018', 'n_tokens_mistral': 2758, 'n_tokens_neox': 2658, 'n_words': 794}