From 086fa29d786b04c1f4872d68fbd65e553e4c5fe9 Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Wed, 22 Sep 2010 00:50:15 -0700 Subject: [PATCH 1/6] Objective-J Preprocessor Tests: fix scoping bug that caused only the last file in FILENAMES to be tested. --- .../Preprocessor/PreprocessorTest.j | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Tests/Objective-J/Preprocessor/PreprocessorTest.j b/Tests/Objective-J/Preprocessor/PreprocessorTest.j index 946ec50c8..2df15d8fc 100644 --- a/Tests/Objective-J/Preprocessor/PreprocessorTest.j +++ b/Tests/Objective-J/Preprocessor/PreprocessorTest.j @@ -7,7 +7,7 @@ var FILENAMES = [ "Class/root-class-one-ivar", "Class/root-class-multiple-ivars", - "Messages/no-parameter", + "Messages/no-parameters", "Messages/one-parameter", "Messages/multiple-parameters", "Messages/ternary-operator-argument" @@ -24,24 +24,27 @@ var FILENAMES = [ for (; index < count; ++index) { - var filename = FILENAMES[index], - testSelector = sel_getUid("test" + FILENAMES[index]) - - class_addMethod(self, testSelector, function(self, _cmd) + (function () { - var filePath = FILE.join(FILE.dirname(module.path), filename + ".j"), - unpreprocessed = FILE.read(filePath, { charset:"UTF-8" }); - preprocessed = ObjectiveJ.preprocess(unpreprocessed).code(), - correct = FILE.read(FILE.join(FILE.dirname(module.path), filename + ".js")); + var filename = FILENAMES[index], + testSelector = sel_getUid("test" + FILENAMES[index]); - preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); - correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); + class_addMethod(self, testSelector, function(self, _cmd) + { + var filePath = FILE.join(FILE.dirname(module.path), filename + ".j"), + unpreprocessed = FILE.read(filePath, { charset:"UTF-8" }), + preprocessed = ObjectiveJ.preprocess(unpreprocessed).code(), + correct = FILE.read(FILE.join(FILE.dirname(module.path), filename + ".js")); - [self assert:preprocessed equals:correct]; - }); + preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); + correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); + + [self assert:preprocessed equals:correct]; + }); + })(); } } @end -[PreprocessorTest alloc]; \ No newline at end of file +[PreprocessorTest alloc]; From 8de508381a354584039624c113954934e588044a Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Fri, 24 Sep 2010 15:01:30 -0700 Subject: [PATCH 2/6] re-organize directory structure of preprocessor tests --- .../{ => OutputTests}/Class/root-class-multiple-ivars.j | 0 .../{ => OutputTests}/Class/root-class-multiple-ivars.js | 0 .../{ => OutputTests}/Class/root-class-one-ivar.j | 0 .../{ => OutputTests}/Class/root-class-one-ivar.js | 0 .../Preprocessor/{ => OutputTests}/Class/root-class.j | 0 .../Preprocessor/{ => OutputTests}/Class/root-class.js | 0 .../{ => OutputTests}/Messages/multiple-parameters.j | 0 .../{ => OutputTests}/Messages/multiple-parameters.js | 0 .../Preprocessor/{ => OutputTests}/Messages/no-parameters.j | 0 .../Preprocessor/{ => OutputTests}/Messages/no-parameters.js | 0 .../Preprocessor/{ => OutputTests}/Messages/one-parameter.j | 0 .../Preprocessor/{ => OutputTests}/Messages/one-parameter.js | 0 .../{ => OutputTests}/Messages/ternary-operator-argument.j | 0 .../{ => OutputTests}/Messages/ternary-operator-argument.js | 0 .../{PreprocessorTest.j => OutputTests/OutputTest.j} | 4 ++-- 15 files changed, 2 insertions(+), 2 deletions(-) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class-multiple-ivars.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class-multiple-ivars.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class-one-ivar.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class-one-ivar.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Class/root-class.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/multiple-parameters.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/multiple-parameters.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/no-parameters.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/no-parameters.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/one-parameter.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/one-parameter.js (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/ternary-operator-argument.j (100%) rename Tests/Objective-J/Preprocessor/{ => OutputTests}/Messages/ternary-operator-argument.js (100%) rename Tests/Objective-J/Preprocessor/{PreprocessorTest.j => OutputTests/OutputTest.j} (95%) diff --git a/Tests/Objective-J/Preprocessor/Class/root-class-multiple-ivars.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class-multiple-ivars.j rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j diff --git a/Tests/Objective-J/Preprocessor/Class/root-class-multiple-ivars.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class-multiple-ivars.js rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js diff --git a/Tests/Objective-J/Preprocessor/Class/root-class-one-ivar.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class-one-ivar.j rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j diff --git a/Tests/Objective-J/Preprocessor/Class/root-class-one-ivar.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class-one-ivar.js rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js diff --git a/Tests/Objective-J/Preprocessor/Class/root-class.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class.j rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j diff --git a/Tests/Objective-J/Preprocessor/Class/root-class.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Class/root-class.js rename to Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js diff --git a/Tests/Objective-J/Preprocessor/Messages/multiple-parameters.j b/Tests/Objective-J/Preprocessor/OutputTests/Messages/multiple-parameters.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/multiple-parameters.j rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/multiple-parameters.j diff --git a/Tests/Objective-J/Preprocessor/Messages/multiple-parameters.js b/Tests/Objective-J/Preprocessor/OutputTests/Messages/multiple-parameters.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/multiple-parameters.js rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/multiple-parameters.js diff --git a/Tests/Objective-J/Preprocessor/Messages/no-parameters.j b/Tests/Objective-J/Preprocessor/OutputTests/Messages/no-parameters.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/no-parameters.j rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/no-parameters.j diff --git a/Tests/Objective-J/Preprocessor/Messages/no-parameters.js b/Tests/Objective-J/Preprocessor/OutputTests/Messages/no-parameters.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/no-parameters.js rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/no-parameters.js diff --git a/Tests/Objective-J/Preprocessor/Messages/one-parameter.j b/Tests/Objective-J/Preprocessor/OutputTests/Messages/one-parameter.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/one-parameter.j rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/one-parameter.j diff --git a/Tests/Objective-J/Preprocessor/Messages/one-parameter.js b/Tests/Objective-J/Preprocessor/OutputTests/Messages/one-parameter.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/one-parameter.js rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/one-parameter.js diff --git a/Tests/Objective-J/Preprocessor/Messages/ternary-operator-argument.j b/Tests/Objective-J/Preprocessor/OutputTests/Messages/ternary-operator-argument.j similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/ternary-operator-argument.j rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/ternary-operator-argument.j diff --git a/Tests/Objective-J/Preprocessor/Messages/ternary-operator-argument.js b/Tests/Objective-J/Preprocessor/OutputTests/Messages/ternary-operator-argument.js similarity index 100% rename from Tests/Objective-J/Preprocessor/Messages/ternary-operator-argument.js rename to Tests/Objective-J/Preprocessor/OutputTests/Messages/ternary-operator-argument.js diff --git a/Tests/Objective-J/Preprocessor/PreprocessorTest.j b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j similarity index 95% rename from Tests/Objective-J/Preprocessor/PreprocessorTest.j rename to Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j index 2df15d8fc..7c97fa2b0 100644 --- a/Tests/Objective-J/Preprocessor/PreprocessorTest.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j @@ -13,7 +13,7 @@ var FILENAMES = [ "Messages/ternary-operator-argument" ]; -@implementation PreprocessorTest : OJTestCase +@implementation OutputTest : OJTestCase { } @@ -47,4 +47,4 @@ var FILENAMES = [ @end -[PreprocessorTest alloc]; +[OutputTest alloc]; From 0802b80c355219cb6bcecc15193a95abab0a8a04 Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Fri, 24 Sep 2010 15:03:22 -0700 Subject: [PATCH 3/6] Make local param shadowing detection print a warning instead of throwing a SyntaxError. This way it's easier to test that particular scenario, since this is actually a bug in the Preprocessor. --- Objective-J/Preprocessor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objective-J/Preprocessor.js b/Objective-J/Preprocessor.js index 75ee38697..1aaa9e432 100644 --- a/Objective-J/Preprocessor.js +++ b/Objective-J/Preprocessor.js @@ -670,7 +670,7 @@ Preprocessor.prototype.method = function(/*Lexer*/ tokens, ivar_names) parameters[parameters.length] = token; if (token in ivar_names) - throw new SyntaxError(this.error_message("*** Method ( "+selector+" ) uses a parameter name that is already in use ( "+token+" )")); + CPLog.warn(this.error_message("*** Warning: Method ( "+selector+" ) uses a parameter name that is already in use ( "+token+" )")); } else if (token == TOKEN_OPEN_PARENTHESIS) { From 8cc61cccfd78debe96eba96a7b332938e6d5377e Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Fri, 24 Sep 2010 15:10:06 -0700 Subject: [PATCH 4/6] add behavior tests for methods, ivars, and inheritance; currently, one of the ivar tests fails due to bug #498 --- .../BehaviorTests/InheritanceTest.j | 131 ++++++++++++++++++ .../Preprocessor/BehaviorTests/IvarTest.j | 117 ++++++++++++++++ .../Preprocessor/BehaviorTests/MethodTest.j | 65 +++++++++ 3 files changed, 313 insertions(+) create mode 100644 Tests/Objective-J/Preprocessor/BehaviorTests/InheritanceTest.j create mode 100644 Tests/Objective-J/Preprocessor/BehaviorTests/IvarTest.j create mode 100644 Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j diff --git a/Tests/Objective-J/Preprocessor/BehaviorTests/InheritanceTest.j b/Tests/Objective-J/Preprocessor/BehaviorTests/InheritanceTest.j new file mode 100644 index 000000000..5fcd7b5f4 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/BehaviorTests/InheritanceTest.j @@ -0,0 +1,131 @@ +@import + +@implementation ParentClass : CPObject +{ + id ivar; +} + +- (CPString)classNameString +{ + return @"ParentClass"; +} + +@end + +@implementation ChildClass : ParentClass +{ +} + +- (id)ivar +{ + return ivar; +} + +- (void)setIvar:(id)newValue +{ + ivar = newValue; +} + +- (CPString)classNameString +{ + return @"ChildClass"; +} + +- (CPString)parentClassNameString +{ + return [super classNameString]; +} + +@end + +@implementation GrandChildClass : ChildClass +{ +} + +- (CPString)classNameString +{ + return @"GrandChildClass"; +} + +- (CPString)parentClassNameString +{ + return [super classNameString]; +} + +- (CPString)grandParentClassNameString +{ + return [super parentClassNameString]; +} + +@end + +@implementation InheritanceTest : OJTestCase +{ + ParentClass parentClass; + ChildClass childClass; + GrandChildClass grandChildClass; +} + +- (void)setUp +{ + parentClass = [[ParentClass alloc] init]; + childClass = [[ChildClass alloc] init]; + grandChildClass = [[GrandChildClass alloc] init]; +} + +- (void)testIvarInheritance +{ + [self assert:nil equals:parentClass.ivar]; + [self assert:nil equals:childClass.ivar]; + [self assert:nil equals:grandChildClass.ivar]; + + parentClass.ivar = 1; + childClass.ivar = 2; + grandChildClass.ivar = 3; + + [self assert:1 equals:parentClass.ivar]; + [self assert:2 equals:childClass.ivar]; + [self assert:3 equals:grandChildClass.ivar]; +} + +- (void)testIvarIndependence +{ + parentClass.ivar = 1; + [self assert:1 equals:parentClass.ivar]; + [self assert:nil equals:childClass.ivar]; + [self assert:nil equals:grandChildClass.ivar]; + + childClass.ivar = 2; + [self assert:1 equals:parentClass.ivar]; + [self assert:2 equals:childClass.ivar]; + [self assert:nil equals:grandChildClass.ivar]; + + grandChildClass.ivar = 3; + [self assert:1 equals:parentClass.ivar]; + [self assert:2 equals:childClass.ivar]; + [self assert:3 equals:grandChildClass.ivar]; +} + +- (void)testMethodInheritance +{ + [self assertThrows:function() + { + [parentClass setIvar:5]; + }]; + [childClass setIvar:5]; + [grandChildClass setIvar:10]; + [self assert:nil equals:parentClass.ivar]; + [self assert:5 equals:childClass.ivar]; + [self assert:10 equals:grandChildClass.ivar]; +} + +- (void)testSuper +{ + [self assert:@"ParentClass" equals:[parentClass classNameString]]; + [self assert:@"ParentClass" equals:[childClass parentClassNameString]]; + [self assert:@"ParentClass" equals:[grandChildClass grandParentClassNameString]]; +} + +@end + + diff --git a/Tests/Objective-J/Preprocessor/BehaviorTests/IvarTest.j b/Tests/Objective-J/Preprocessor/BehaviorTests/IvarTest.j new file mode 100644 index 000000000..d0c38aad9 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/BehaviorTests/IvarTest.j @@ -0,0 +1,117 @@ +@import + +@implementation IvarTestClass : CPObject +{ + id ivar1 @accessors; + var ivar2 @accessors(readonly); + CPNumber ivar3; +} + +- (void)setIvar1UsingEval:(id)value +{ + eval(@"var ivar1 = " + value); +} + +- (void)doNothingToIvar1UsingEval:(id)value +{ + (function() + { + eval(@"var ivar1 = " + value); + })(); +} + +- (void)setIvar1DespiteAWithStatement:(id)value +{ + with({}) + { + ivar1 = value; + } +} + +- (void)doNothingToIvar1BecauseOfWithStatement:(id)value +{ + with({'ivar1':null}) + { + ivar1 = value; + } +} + +- (void)setIvar1UsingAShadowingLocalVariable:(id)ivar1 +{ + self.ivar1 = ivar1; +} + +@end + +@implementation IvarTest : OJTestCase +{ + IvarTestClass testClass; +} + +- (void)setUp +{ + testClass = [[IvarTestClass alloc] init]; +} + +- (void)testDirectAccess +{ + [self assert:nil equals:testClass.ivar1]; + testClass.ivar1 = 5; + [self assert:5 equals:testClass.ivar1]; +} + +- (void)testWithStatementInMethod +{ + [self assert:nil equals:testClass.ivar1]; + [testClass setIvar1DespiteAWithStatement:5]; + [self assert:5 equals:testClass.ivar1]; + [testClass doNothingToIvar1BecauseOfWithStatement:10]; + [self assert:5 equals:testClass.ivar1]; +} + +- (void)testEvalInMethod +{ + [self assert:nil equals:testClass.ivar1]; + [testClass setIvar1UsingEval:5]; + [self assert:5 equals:testClass.ivar1]; + [testClass doNothingToIvar1UsingEval:10]; + [self assert:5 equals:testClass.ivar1]; +} + +- (void)testIvarShadowing +{ + [self assert:nil equals:testClass.ivar1]; + [testClass setIvar1UsingAShadowingLocalVariable:5]; + [self assert:5 equals:testClass.ivar1]; +} + +- (void)testAccessorGeneration +{ + [self assert:nil equals:[testClass ivar1]]; + [testClass setIvar1:10]; + [self assert:10 equals:[testClass ivar1]]; + [self assert:10 equals:testClass.ivar1]; + + [self assert:nil equals:[testClass ivar2]]; + testClass.ivar2 = 5; + [self assert:5 equals:[testClass ivar2]]; + [self assert:5 equals:testClass.ivar2]; + [self assertThrows:function() + { + [testClass setIvar2:6]; + }]; + [self assert:5 equals:[testClass ivar2]]; + + [self assert:nil equals:testClass.ivar3]; + [self assertThrows:function() + { + [testClass ivar3]; + }]; + [self assertThrows:function() + { + [testClass setIvar3:20]; + }]; + [self assert:nil equals:testClass.ivar3]; +} + +@end diff --git a/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j b/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j new file mode 100644 index 000000000..0a4d74e69 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j @@ -0,0 +1,65 @@ +@import + +@implementation MathClass : CPObject +{ +} + +- (CPNumber)five +{ + return 5; +} + +- (CPNumber)sqrt:(CPNumber)operand +{ + return Math.sqrt(operand); +} + +- (CPNumber)multiply:(CPNumber)firstOperand with:(CPNumber)secondOperand +{ + return firstOperand * secondOperand; +} + +- (CPNumber)multiply:(CPNumber)operand, ... +{ + var product; + + for (var i = 0, ii = arguments.length; i < ii; ++i) + product = product ? product * arguments[i] : arguments[i]; + + return product; +} + +@end + +@implementation MethodTest : OJTestCase +{ + MathClass testClass; +} + +- (void)setUp +{ + testClass = [[MathClass alloc] init]; +} + +- (void)testNoParameters +{ + [self assert:5 equals:[testClass five]]; +} + +- (void)testOneParameter +{ + [self assert:2 equals:[testClass sqrt:4]]; +} + +- (void)testTwoParameters +{ + [self assert:6 equals:[testClass multiply:2 with:3]]; +} + +- (void)testVarArgs +{ + [self assert:30 equals:[testClass multiply:2,3,5]]; + [self assert:2310 equals:[testClass multiply:2,3,5,7,11]]; +} + +@end From e62fd3cf403ca131daf43647ea62f16bdc0aad2d Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Fri, 24 Sep 2010 16:46:31 -0700 Subject: [PATCH 5/6] Add a test case to test some reductions of regexes that current cause errors in the Preprocessor. --- .../OutputTests/Misc/regex-simple-char-classes.j | 10 ++++++++++ .../OutputTests/Misc/regex-simple-char-classes.js | 10 ++++++++++ .../Preprocessor/OutputTests/OutputTest.j | 13 +++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.j create mode 100644 Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.js diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.j b/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.j new file mode 100644 index 000000000..dbc548b70 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.j @@ -0,0 +1,10 @@ +/[\{]/; +/[\}]/; +/[@]/; +/[\[]/; +/[\]]/; +/[#]/; +/[\(]/; +/[\)]/; +/(\[)/; +/(\])/; diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.js b/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.js new file mode 100644 index 000000000..dbc548b70 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/OutputTests/Misc/regex-simple-char-classes.js @@ -0,0 +1,10 @@ +/[\{]/; +/[\}]/; +/[@]/; +/[\[]/; +/[\]]/; +/[#]/; +/[\(]/; +/[\)]/; +/(\[)/; +/(\])/; diff --git a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j index 7c97fa2b0..f9048e927 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j @@ -10,7 +10,9 @@ var FILENAMES = [ "Messages/no-parameters", "Messages/one-parameter", "Messages/multiple-parameters", - "Messages/ternary-operator-argument" + "Messages/ternary-operator-argument", + + "Misc/regex-simple-char-classes" ]; @implementation OutputTest : OJTestCase @@ -33,11 +35,14 @@ var FILENAMES = [ { var filePath = FILE.join(FILE.dirname(module.path), filename + ".j"), unpreprocessed = FILE.read(filePath, { charset:"UTF-8" }), - preprocessed = ObjectiveJ.preprocess(unpreprocessed).code(), + preprocessed, correct = FILE.read(FILE.join(FILE.dirname(module.path), filename + ".js")); - preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); - correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); + [self assertNoThrow:function() { + preprocessed = ObjectiveJ.preprocess(unpreprocessed).code(), + preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); + correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); + }]; [self assert:preprocessed equals:correct]; }); From 2cc6c54fbfada65a3f898df2dbb1099aa94e7166 Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Tue, 28 Sep 2010 17:45:00 -0700 Subject: [PATCH 6/6] Start index for var-args needs to be 2, not 0. I only got lucky that it worked anyway. --- Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j b/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j index 0a4d74e69..e1e9a6df9 100644 --- a/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j +++ b/Tests/Objective-J/Preprocessor/BehaviorTests/MethodTest.j @@ -23,7 +23,7 @@ { var product; - for (var i = 0, ii = arguments.length; i < ii; ++i) + for (var i = 2, ii = arguments.length; i < ii; ++i) product = product ? product * arguments[i] : arguments[i]; return product;