Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes private types from the header file.
Change on 2015/04/02 by kstanger <kstanger@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=90154286
- Loading branch information
Showing
8 changed files
with
124 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
translator/src/test/java/com/google/devtools/j2objc/gen/TypeDeclarationGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
/* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package com.google.devtools.j2objc.gen; | |||
|
|||
import com.google.devtools.j2objc.GenerationTest; | |||
|
|||
import java.io.IOException; | |||
|
|||
/** | |||
* Tests for {@link TypeDeclarationGenerator}. | |||
* | |||
* @author Keith Stanger | |||
*/ | |||
public class TypeDeclarationGeneratorTest extends GenerationTest { | |||
|
|||
public void testAnonymousClassDeclaration() throws IOException { | |||
String translation = translateSourceFile( | |||
"public class Example { Runnable run = new Runnable() { public void run() {} }; }", | |||
"Example", "Example.m"); | |||
assertTranslation(translation, "@interface Example_$1 : NSObject < JavaLangRunnable >"); | |||
assertTranslation(translation, "- (void)run;"); | |||
// Outer reference is not required. | |||
assertNotInTranslation(translation, "Example *this"); | |||
assertNotInTranslation(translation, "- (id)initWithExample:"); | |||
} | |||
|
|||
public void testAnonymousConcreteSubclassOfGenericAbstractType() throws IOException { | |||
String translation = translateSourceFile( | |||
"public class Test {" | |||
+ " interface FooInterface<T> { public void foo1(T t); public void foo2(); }" | |||
+ " abstract static class Foo<T> implements FooInterface<T> { public void foo2() { } }" | |||
+ " Foo<Integer> foo = new Foo<Integer>() {" | |||
+ " public void foo1(Integer i) { } }; }", | |||
"Test", "Test.m"); | |||
assertTranslation(translation, "foo1WithId:(JavaLangInteger *)i"); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...or/src/test/java/com/google/devtools/j2objc/translate/PrivateDeclarationResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
/* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package com.google.devtools.j2objc.translate; | |||
|
|||
import com.google.devtools.j2objc.GenerationTest; | |||
|
|||
import java.io.IOException; | |||
|
|||
/** | |||
* Unit tests for {@link PrivateDeclarationResolver}. | |||
* | |||
* @author Keith Stanger | |||
*/ | |||
public class PrivateDeclarationResolverTest extends GenerationTest { | |||
|
|||
public void testPrivateSuperclassOfPublicClass() throws IOException { | |||
String translation = translateSourceFile( | |||
"class Test { private static class A {} public static class B extends A {} }", | |||
"Test", "Test.h"); | |||
// Make sure the private superclass is still declared in the header. | |||
assertTranslation(translation, "@interface Test_A"); | |||
} | |||
|
|||
public void testPrivateGenericSuperclassOfPublicClass() throws IOException { | |||
String translation = translateSourceFile( | |||
"class Test { private static class A<T> {} public static class B extends A<String> {} }", | |||
"Test", "Test.h"); | |||
// Make sure the private superclass is still declared in the header. | |||
assertTranslation(translation, "@interface Test_A"); | |||
} | |||
|
|||
public void testPublicClassInsidePrivateClass() throws IOException { | |||
String translation = translateSourceFile( | |||
"class Test { private static class A { public static class B {} } }", "Test", "Test.h"); | |||
// "B" should not be public because it is inside the private class "A". | |||
assertNotInTranslation(translation, "Test_A_B"); | |||
} | |||
} |