From 392aafb360a6b5b221baaaeda794065e0007abdf Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Thu, 16 May 2013 12:05:57 +0200 Subject: [PATCH] Revert "Revert "New: Added test cases for some preprocess directives in OutputTest.j"" This reverts commit 5e6c89ca8bd9784cb058ec9c4f581682b815b8e5. Conflicts: Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j --- .../Class/root-class-multiple-ivars.j | 4 ++-- .../Class/root-class-multiple-ivars.js | 2 +- .../Misc/preprocess-if-directives.j | 24 +++++++++++++++++++ .../Misc/preprocess-if-directives.js | 4 ++++ .../Preprocessor/OutputTests/OutputTest.j | 3 ++- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.j create mode 100644 Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.js diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j index 544d76330..50d1fa504 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j @@ -5,6 +5,6 @@ CPArray array; CPString string; - int * pointer; + int integer; } -@end \ No newline at end of file +@end diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js index 9d7573c30..7eba069a9 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js @@ -2,6 +2,6 @@ var the_class = objj_allocateClassPair(Nil, "Class"), meta_class = the_class.isa; -class_addIvars(the_class,[new objj_ivar("ivar"), new objj_ivar("array"), new objj_ivar("string"), new objj_ivar("pointer")]); +class_addIvars(the_class,[new objj_ivar("ivar"), new objj_ivar("array"), new objj_ivar("string"), new objj_ivar("integer")]); objj_registerClassPair(the_class); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.j b/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.j new file mode 100644 index 000000000..beb6598fb --- /dev/null +++ b/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.j @@ -0,0 +1,24 @@ +#define xxxx 3 +#ifndef carlberg + var name = "Martin" + #if xxxx == 3 + var verb = "Was"; + #ifdef yyyy + var action = "Home"; + #else + #if zzzzz + var action = "Away"; + #else + var action = "Here" + #endif + #endif + #else + var verb = "is"; + #endif +#else + var name = "Alexander"; +#endif + +#define f(x) x > 3 + +if (f(4)) var a = 3; diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.js b/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.js new file mode 100644 index 000000000..d8486bd74 --- /dev/null +++ b/Tests/Objective-J/Preprocessor/OutputTests/Misc/preprocess-if-directives.js @@ -0,0 +1,4 @@ +var name="Martin"; +var verb="Was"; +var action="Here"; +if (4 > 3) var a = 3; \ No newline at end of file diff --git a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j index 7c0e45627..d37814485 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/OutputTest.j @@ -11,6 +11,7 @@ var FILENAMES = [ "Messages/one-parameter", "Messages/multiple-parameters", "Messages/ternary-operator-argument", + "Misc/preprocess-if-directives", // TODO Re-enable this test when the new Objective-J parser has been enabled. // Before that it will fail with "*** Expected "pragma" to follow # but instead saw "]".". @@ -41,7 +42,7 @@ var FILENAMES = [ correct = FILE.read(FILE.join(FILE.dirname(module.path), filename + ".js")); [self assertNoThrow:function() { - preprocessed = ObjectiveJ.preprocess(unpreprocessed).code(); + preprocessed = ObjectiveJ.ObjJAcornCompiler.compileToExecutable(unpreprocessed).code(); preprocessed = compressor.compress(preprocessed, { charset : "UTF-8", useServer : true }); correct = compressor.compress(correct, { charset : "UTF-8", useServer : true }); }];