From 382e59afd3d5aa04b8448e9fa218b50c3896c7f5 Mon Sep 17 00:00:00 2001 From: yoavgurevich Date: Wed, 14 May 2014 12:19:44 -0400 Subject: [PATCH 1/4] Added line note fixes to issue 62 logic in interface.js --- .gitignore | 1 + src/filesystem/interface.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c794f4b..45e7df2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules bower_components *~ +/logicnotes.js diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index cf8617d..175dab5 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -22,7 +22,7 @@ define(function(require) { var STDIN = require('src/constants').STDIN; var STDOUT = require('src/constants').STDOUT; var STDERR = require('src/constants').STDERR; - var FD = require('src/constants').FIRST_DESCRIPTOR; + var FIRST_DESCRIPTOR = require('src/constants').FIRST_DESCRIPTOR; // The core fs operations live on impl var impl = require('src/filesystem/implementation'); @@ -87,7 +87,7 @@ define(function(require) { // Safely expose the list of open files and file // descriptor management functions var openFiles = {}; - var nextDescriptor = 3; + var nextDescriptor = FIRST_DESCRIPTOR; Object.defineProperty(this, "openFiles", { get: function() { return openFiles; } }); From 6b2a023deac21fe6d05f6fc2229a5cf444a52f42 Mon Sep 17 00:00:00 2001 From: yoavgurevich Date: Wed, 14 May 2014 16:02:46 -0400 Subject: [PATCH 2/4] Corrected conflicting syntax and added testing clause for file descriptor argument value --- src/filesystem/interface.js | 2 +- tests/spec/fs.open.spec.js | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index 175dab5..a2ad302 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -82,7 +82,7 @@ define(function(require) { fs.stdin = STDIN; fs.stdout = STDOUT; fs.stderr = STDERR; - fs.firstFD = FD; + fs.firstFD = FIRST_DESCRIPTOR; // Safely expose the list of open files and file // descriptor management functions diff --git a/tests/spec/fs.open.spec.js b/tests/spec/fs.open.spec.js index 5e05661..a0cfcb3 100644 --- a/tests/spec/fs.open.spec.js +++ b/tests/spec/fs.open.spec.js @@ -58,7 +58,7 @@ define(["Filer", "util"], function(Filer, util) { it('should return a unique file descriptor', function(done) { var fs = util.fs(); - var fd1 + var fd1; fs.open('/file1', 'w+', function(error, fd) { if(error) throw error; @@ -75,6 +75,25 @@ define(["Filer", "util"], function(Filer, util) { }); }); + it('should return the argument value of the file descriptor index matching the value set by the first useable file descriptor constant', function(done) { + var fs = util.fs(); + var openFileDescription = require('src/open-file-description'); + fs.firstFD = require('src/constants').FIRST_DESCRIPTOR; + var fd1; + + fs.open('/file1', 'w+', function(error, fd) { + if(error) throw error; + expect(error).not.to.exist; + expect(fd).to.be.a('number'); + expect(fd).not.to.equal(fd1); + + this.allocDescriptor = function(openFileDescription) { + expect(fd).to.equal(fs.firstFD); + }; + done(); + }); + }); + it('should create a new file when flagged for write', function(done) { var fs = util.fs(); From 4d24ab2c360d19dd542b5f06b9fa589aa9fd6cb6 Mon Sep 17 00:00:00 2001 From: yoavgurevich Date: Fri, 16 May 2014 11:43:54 -0400 Subject: [PATCH 3/4] Fixed logic, format, and dependencies according to line note comments from last pull request. Tested on apache localhost server. --- .gitignore | 1 - src/constants.js | 4 ++-- tests/spec/fs.open.spec.js | 9 ++------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 45e7df2..c794f4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ node_modules bower_components *~ -/logicnotes.js diff --git a/src/constants.js b/src/constants.js index 6c6a59e..bad5944 100644 --- a/src/constants.js +++ b/src/constants.js @@ -68,7 +68,7 @@ define(function(require) { SUPER_NODE_ID: '00000000-0000-0000-0000-000000000000', - //Reserved FileDescriptors for streams + // Reserved File Descriptors for streams STDIN: 0, STDOUT: 1, STDERR: 2, @@ -80,4 +80,4 @@ define(function(require) { } }; -}); \ No newline at end of file +}); diff --git a/tests/spec/fs.open.spec.js b/tests/spec/fs.open.spec.js index a0cfcb3..3b8b0ec 100644 --- a/tests/spec/fs.open.spec.js +++ b/tests/spec/fs.open.spec.js @@ -77,19 +77,14 @@ define(["Filer", "util"], function(Filer, util) { it('should return the argument value of the file descriptor index matching the value set by the first useable file descriptor constant', function(done) { var fs = util.fs(); - var openFileDescription = require('src/open-file-description'); - fs.firstFD = require('src/constants').FIRST_DESCRIPTOR; + var firstFD = require('src/constants').FIRST_DESCRIPTOR; var fd1; fs.open('/file1', 'w+', function(error, fd) { if(error) throw error; expect(error).not.to.exist; expect(fd).to.be.a('number'); - expect(fd).not.to.equal(fd1); - - this.allocDescriptor = function(openFileDescription) { - expect(fd).to.equal(fs.firstFD); - }; + expect(fd).to.equal(firstFD); done(); }); }); From 067f9beb888aa6cf7aa92e362d3e636937c3a33c Mon Sep 17 00:00:00 2001 From: yoavgurevich Date: Fri, 16 May 2014 17:17:50 -0400 Subject: [PATCH 4/4] Final revisions on removal of arbitrary logic and indentation issues --- src/filesystem/interface.js | 1 - tests/spec/fs.open.spec.js | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index a2ad302..c00c381 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -82,7 +82,6 @@ define(function(require) { fs.stdin = STDIN; fs.stdout = STDOUT; fs.stderr = STDERR; - fs.firstFD = FIRST_DESCRIPTOR; // Safely expose the list of open files and file // descriptor management functions diff --git a/tests/spec/fs.open.spec.js b/tests/spec/fs.open.spec.js index 3b8b0ec..45d9098 100644 --- a/tests/spec/fs.open.spec.js +++ b/tests/spec/fs.open.spec.js @@ -82,9 +82,7 @@ define(["Filer", "util"], function(Filer, util) { fs.open('/file1', 'w+', function(error, fd) { if(error) throw error; - expect(error).not.to.exist; - expect(fd).to.be.a('number'); - expect(fd).to.equal(firstFD); + expect(fd).to.equal(firstFD); done(); }); });