<commit_before>retro = require './retro'
should = require 'should'
nointro = require 'gametime-nointro'

cores =
  snes9x_libretro:
    library_name: 'Snes9x'
    roms: [
      nointro_name: 'Super Mario World (USA)'
      nointro_console: 'Nintendo - Super Nintendo Entertainment System'
    ]
  dinothawr_libretro:
    library_name: 'Dinothawr'

for corename, coreinfo of cores
  do (corename, coreinfo) ->
    describe "retro.getCore('#{corename}')", ->
      core = null
      before (done) ->
        retro.getCore(corename).then (c) ->
          core = c
          core.on 'videorefresh', (data, width, height) ->
            data.should.be.a.ArrayBuffer
            width.should.be.a.Number
            height.should.be.a.Number
          core.on 'inputstate', (port, device, idx, id) ->
            port.should.be.a.Number
            device.should.be.a.Number
            idx.should.be.a.Number
            id.should.be.a.Number
          core.on 'audiosamplebatch', (left, right, frames) ->
            left.should.be.a.ArrayBuffer
            right.should.be.a.ArrayBuffer
            frames.should.be.a.Number
          core.on 'environment', (cmd, value) ->
            cmd.should.be.a.Number
          done()
      it "core should exist", ->
        core.should.exist
      it 'core.api_version() == 1', ->
        core.api_version().should.equal 1
      it 'core.getSystemInfo()', ->
        info = core.getSystemInfo()
        info.library_name.should.be.a.String
        info.library_name.should.equal coreinfo.library_name
        info.library_version.should.be.a.String
        info.valid_extensions.should.be.a.String
        info.need_fullpath.should.be.a.Boolean
        info.block_extract.should.be.a.Boolean
      it 'core.getSystemAVInfo()', ->
        info = core.getSystemAVInfo()
        info.should.have.property 'geometry'
        info.geometry.base_width.should.be.a.Number
        info.geometry.base_height.should.be.a.Number
        info.geometry.max_width.should.be.a.Number
        info.geometry.max_height.should.be.a.Number
        info.geometry.aspect_ratio.should.be.a.Number
        info.should.have.property 'timing'
        info.timing.fps.should.be.a.Number
        info.timing.sample_rate.should.be.a.Number
      it 'core.getRegion()', ->
        core.getRegion().should.be.within 0, 1
      if coreinfo.roms
        for rom in coreinfo.roms
          do (rom) ->
            it "running #{rom.nointro_name} for 5 frames", (done) ->
              nointro.getROM rom
              .then (buffer) ->
                core.loadGame buffer
                core.run() for a in [1..5]
                done()<commit_msg>Extend timeouts for testing with mocha.<commit_after>retro = require './retro'
should = require 'should'
nointro = require 'gametime-nointro'

cores =
  snes9x_libretro:
    library_name: 'Snes9x'
    roms: [
      nointro_name: 'Super Mario World (USA)'
      nointro_console: 'Nintendo - Super Nintendo Entertainment System'
    ]
  dinothawr_libretro:
    library_name: 'Dinothawr'

for corename, coreinfo of cores
  do (corename, coreinfo) ->
    describe "retro.getCore('#{corename}')", ->
      core = null
      before (done) ->
        this.timeout 4000
        retro.getCore(corename).then (c) ->
          core = c
          core.on 'videorefresh', (data, width, height) ->
            data.should.be.a.ArrayBuffer
            width.should.be.a.Number
            height.should.be.a.Number
          core.on 'inputstate', (port, device, idx, id) ->
            port.should.be.a.Number
            device.should.be.a.Number
            idx.should.be.a.Number
            id.should.be.a.Number
          core.on 'audiosamplebatch', (left, right, frames) ->
            left.should.be.a.ArrayBuffer
            right.should.be.a.ArrayBuffer
            frames.should.be.a.Number
          core.on 'environment', (cmd, value) ->
            cmd.should.be.a.Number
          done()
      it "core should exist", ->
        core.should.exist
      it 'core.api_version() == 1', ->
        core.api_version().should.equal 1
      it 'core.getSystemInfo()', ->
        info = core.getSystemInfo()
        info.library_name.should.be.a.String
        info.library_name.should.equal coreinfo.library_name
        info.library_version.should.be.a.String
        info.valid_extensions.should.be.a.String
        info.need_fullpath.should.be.a.Boolean
        info.block_extract.should.be.a.Boolean
      it 'core.getSystemAVInfo()', ->
        info = core.getSystemAVInfo()
        info.should.have.property 'geometry'
        info.geometry.base_width.should.be.a.Number
        info.geometry.base_height.should.be.a.Number
        info.geometry.max_width.should.be.a.Number
        info.geometry.max_height.should.be.a.Number
        info.geometry.aspect_ratio.should.be.a.Number
        info.should.have.property 'timing'
        info.timing.fps.should.be.a.Number
        info.timing.sample_rate.should.be.a.Number
      it 'core.getRegion()', ->
        core.getRegion().should.be.within 0, 1
      if coreinfo.roms
        for rom in coreinfo.roms
          do (rom) ->
            it "running #{rom.nointro_name} for 5 frames", (done) ->
              this.timeout 4000
              nointro.getROM rom
              .then (buffer) ->
                core.loadGame buffer
                core.run() for a in [1..5]
                done()
{'fraction_non_alphanumeric': 0.12282326787699148, 'fraction_numerical': 0.004816598740274175, 'mean_word_length': 1.9454446262956901, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '1486491', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1704, 'n_words': 300}