field_test.py 1.1 KB

1234567891011121314151617181920212223242526
  1. from field import FieldParser
  2. from java_file import JavaFile
  3. import java_file
  4. def test(input :str, expected_output :str) -> None:
  5. file = JavaFile()
  6. FieldParser().parse(file, input.split())
  7. print(file.first().string())
  8. print(expected_output)
  9. print(file.first().string() == expected_output)
  10. print()
  11. if __name__ == '__main__':
  12. test('.field public static id:I', \
  13. 'public static Integer id;')
  14. test('.field public volatile id:I', \
  15. 'public volatile Integer id;')
  16. test('.field final synthetic a:Lcom/lifx/app/MainActivity;', \
  17. 'final com.lifx.app.MainActivity a; //synthetic')
  18. test('.field public static final a:Lcom/lifx/app/DiagnosticsActivity$Companion$queryWANState$2$1;', \
  19. 'public static final com.lifx.app.DiagnosticsActivity$Companion$queryWANState$2$1 a;')
  20. test('.field a:Lcom/lifx/app/controller/ControlTab;', \
  21. 'com.lifx.app.controller.ControlTab a;')
  22. test('.field public static final enum a:Lcom/lifx/app/controller/ControlTab;', \
  23. 'public static final com.lifx.app.controller.ControlTab a;')