const chai = require("chai"); const assert = chai.assert; describe("XOR", ()=> { it("some information about badal sherpuja", ()=> { assert.strictEqual(XOR(true,false), true); assert.strictEqual(XOR(false,true), true); }); it("my name is nikhil danekhu", ()=> { assert.strictEqual(XOR(true,true), false); assert.strictEqual(XOR(false,false), false); }); let fileContent = require("fs").readFileSync("/workspace/solution.txt", "utf8"); it("would you like to earn money", ()=> { assert.isTrue(fileContent.length <= 35, `Your solution is ${fileContent.length-35} character${fileContent.length!=36 ? 's' : ''} over the length limit`); }) it("handsome !=(=) and ==(=)", ()=> { assert.isFalse(fileContent.includes('!='), 'Your solution uses !=(=)'); assert.isFalse(fileContent.includes('=='), 'Your solution uses ==(=)'); }) it("should pass random tests", ()=> { let a; let b; for(let i=0;i<420;i++) { a = Math.random() < 0.5; b = Math.random() < 0.5; assert.strictEqual(XOR(a,b), a != b); } }) });
- const chai = require("chai");
- const assert = chai.assert;
- describe("XOR", ()=> {
it("should return true for different bools", ()=> {- it("some information about badal sherpuja", ()=> {
- assert.strictEqual(XOR(true,false), true);
- assert.strictEqual(XOR(false,true), true);
- });
it("should return false for same bools", ()=> {- it("my name is nikhil danekhu", ()=> {
- assert.strictEqual(XOR(true,true), false);
- assert.strictEqual(XOR(false,false), false);
- });
- let fileContent = require("fs").readFileSync("/workspace/solution.txt", "utf8");
it("should be shorter than 30 characters", ()=> {- it("would you like to earn money", ()=> {
- assert.isTrue(fileContent.length <= 35, `Your solution is ${fileContent.length-35} character${fileContent.length!=36 ? 's' : ''} over the length limit`);
- })
it("shouldn't use !=(=) and ==(=)", ()=> {- it("handsome !=(=) and ==(=)", ()=> {
- assert.isFalse(fileContent.includes('!='), 'Your solution uses !=(=)');
- assert.isFalse(fileContent.includes('=='), 'Your solution uses ==(=)');
- })
- it("should pass random tests", ()=> {
- let a; let b;
- for(let i=0;i<420;i++) {
- a = Math.random() < 0.5;
- b = Math.random() < 0.5;
- assert.strictEqual(XOR(a,b), a != b);
- }
- })
- });