<commit_before>var assert = require('assert');
var fs     = require('fs');
var mocha  = require('mocha');
var sinon  = require('sinon');
var gpio   = require('../rpi-gpio.js');

var PATH = '/sys/class/gpio';

function getCpuInfo(revision) {
    revision = revision || '0002';
    return 'Processor   : ARMv6-compatible processor rev 7 (v6l)\nBogoMIPS    : 697.95\nFeatures    : swp half thumb fastmult vfp edsp java tls\nCPU implementer : 0x41\nCPU architecture: 7\nCPU variant : 0x0\nCPU part    : 0xb76\nCPU revision    : 7\n\n\nHardware    : BCM2708\nRevision    : ' + revision + '\nSerial   : 000000009a5d9c22';
}

describe('rpi-gpio', function() {

    before(function() {
        sinon.stub(fs, 'writeFile').yieldsAsync();
        sinon.stub(fs, 'exists').yieldsAsync(false);
        sinon.stub(fs, 'readFile')
            .withArgs('/proc/cpuinfo').yieldsAsync(null, getCpuInfo());
    });

    beforeEach(function() {
        gpio.reset();
        gpio.setMode(gpio.MODE_BCM);
        gpio.version = 1;

        fs.writeFile.reset();
        fs.exists.reset();
        fs.readFile.reset();
    });<commit_msg>Add stubs for epoll and fs methods<commit_after>var assert = require('assert');
var fs     = require('fs');
var mocha  = require('mocha');
var sinon  = require('sinon');

// Stub epoll module
epoll = {}
require('epoll').Epoll = function() {
    return epoll;
}

var gpio   = require('../rpi-gpio.js');

var PATH = '/sys/class/gpio';

function getCpuInfo(revision) {
    revision = revision || '0002';
    return 'Processor   : ARMv6-compatible processor rev 7 (v6l)\nBogoMIPS    : 697.95\nFeatures    : swp half thumb fastmult vfp edsp java tls\nCPU implementer : 0x41\nCPU architecture: 7\nCPU variant : 0x0\nCPU part    : 0xb76\nCPU revision    : 7\n\n\nHardware    : BCM2708\nRevision    : ' + revision + '\nSerial   : 000000009a5d9c22';
}

function stubEpoll() {
    epoll = {
        add: sinon.stub()
    }
}

describe('rpi-gpio', function() {

    before(function() {
        sinon.stub(fs, 'writeFile').yieldsAsync();
        sinon.stub(fs, 'exists').yieldsAsync(false);
        sinon.stub(fs, 'openSync').returns(1)
        sinon.stub(fs, 'readSync')
        sinon.stub(fs, 'readFile')
            .withArgs('/proc/cpuinfo').yieldsAsync(null, getCpuInfo());
    });

    beforeEach(function() {
        gpio.reset();
        gpio.setMode(gpio.MODE_BCM);
        gpio.version = 1;

        fs.writeFile.reset();
        fs.exists.reset();
        fs.readFile.reset();

        stubEpoll()
    });
{'fraction_non_alphanumeric': 0.15866719555731854, 'fraction_numerical': 0.032130107100357, 'mean_word_length': 2.803921568627451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2167693', 'n_tokens_mistral': 944, 'n_tokens_neox': 876, 'n_words': 168}