Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #71 from xcthulhu/c++
Browse files Browse the repository at this point in the history
C++11
  • Loading branch information
jhoffner committed Aug 13, 2014
2 parents cd609d0 + 04b2fab commit 95e529b
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions test/runners/cpp_spec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
var expect = require('chai').expect;
var runner = require('../../lib/runners/cpp');

describe( 'c++ runner', function(){
describe( '.run', function(){
it( 'should handle basic code evaluation', function(done){
var solution = ['#include <iostream>',
'int main()',
'{ std::cout << "\\\"Within C++, there is a much smaller and cleaner language struggling to get out.\\\" - Bjarn Stroustrup"; }'
].join('\n');
describe('c++ runner', function () {
describe('.run', function () {
it('should handle basic code evaluation', function (done) {
var solution = [
'#include <iostream>',
'int main()',
'{ std::cout << "\\\"Within C++, there is a much smaller and cleaner language struggling to get out.\\\" - Bjarn Stroustrup"; }'
].join('\n');

runner.run({language: 'c++', solution: solution}, function(buffer) {
runner.run({language: 'c++', solution: solution}, function (buffer) {
expect(buffer.stdout).to.equal("\"Within C++, there is a much smaller and cleaner language struggling to get out.\" - Bjarn Stroustrup");
done();
});
});
it('should handle C++11 nonsense', function (done) {
var solution = [
'#include "stdio.h"',
'int main() {',
' auto f = []{ printf("Finally, lambdas in C++. Now if we had typeclasses, purity and laziness we might have a reasonable functional programming language."); };',
' f();',
'}'
].join('\n');

runner.run({language: 'c++', solution: solution}, function (buffer) {
expect(buffer.stdout).to.equal("Finally, lambdas in C++. Now if we had typeclasses, purity and laziness we might have a reasonable functional programming language.");
done();
});
});
it('should handle setup code and imports', function (done) {
runner.run({
language: 'cpp',
setup: [
'int square(int a) { return a * a ; }'
].join('\n'),
solution: [
'#include <iostream>',
'int square(int);',
'int main() {',
' std::cout << square(6);',
'}',
].join('\n')
}, function (buffer) {
expect(buffer.stdout).to.equal('36');
done();
});
});
});
});

0 comments on commit 95e529b

Please sign in to comment.