OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 library engine.ast_test; | 3 library engine.ast_test; |
4 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 4 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
6 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 6 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
7 import 'package:analyzer_experimental/src/generated/ast.dart'; | 7 import 'package:analyzer_experimental/src/generated/ast.dart'; |
8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; | 8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; |
9 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem
ent; | 9 import 'package:analyzer_experimental/src/generated/element.dart' show ClassElem
ent; |
10 import 'package:unittest/unittest.dart' as _ut; | 10 import 'package:unittest/unittest.dart' as _ut; |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 final __test = new SimpleIdentifierTest(); | 706 final __test = new SimpleIdentifierTest(); |
707 runJUnitTest(__test, __test.test_inReferenceContext); | 707 runJUnitTest(__test, __test.test_inReferenceContext); |
708 }); | 708 }); |
709 _ut.test('test_inSetterContext', () { | 709 _ut.test('test_inSetterContext', () { |
710 final __test = new SimpleIdentifierTest(); | 710 final __test = new SimpleIdentifierTest(); |
711 runJUnitTest(__test, __test.test_inSetterContext); | 711 runJUnitTest(__test, __test.test_inSetterContext); |
712 }); | 712 }); |
713 }); | 713 }); |
714 } | 714 } |
715 } | 715 } |
716 class AssignmentKind implements Enum<AssignmentKind> { | 716 class AssignmentKind extends Enum<AssignmentKind> { |
717 static final AssignmentKind BINARY = new AssignmentKind('BINARY', 0); | 717 static final AssignmentKind BINARY = new AssignmentKind('BINARY', 0); |
718 static final AssignmentKind COMPOUND_LEFT = new AssignmentKind('COMPOUND_LEFT'
, 1); | 718 static final AssignmentKind COMPOUND_LEFT = new AssignmentKind('COMPOUND_LEFT'
, 1); |
719 static final AssignmentKind COMPOUND_RIGHT = new AssignmentKind('COMPOUND_RIGH
T', 2); | 719 static final AssignmentKind COMPOUND_RIGHT = new AssignmentKind('COMPOUND_RIGH
T', 2); |
720 static final AssignmentKind POSTFIX_INC = new AssignmentKind('POSTFIX_INC', 3)
; | 720 static final AssignmentKind POSTFIX_INC = new AssignmentKind('POSTFIX_INC', 3)
; |
721 static final AssignmentKind PREFIX_DEC = new AssignmentKind('PREFIX_DEC', 4); | 721 static final AssignmentKind PREFIX_DEC = new AssignmentKind('PREFIX_DEC', 4); |
722 static final AssignmentKind PREFIX_INC = new AssignmentKind('PREFIX_INC', 5); | 722 static final AssignmentKind PREFIX_INC = new AssignmentKind('PREFIX_INC', 5); |
723 static final AssignmentKind PREFIX_NOT = new AssignmentKind('PREFIX_NOT', 6); | 723 static final AssignmentKind PREFIX_NOT = new AssignmentKind('PREFIX_NOT', 6); |
724 static final AssignmentKind SIMPLE_LEFT = new AssignmentKind('SIMPLE_LEFT', 7)
; | 724 static final AssignmentKind SIMPLE_LEFT = new AssignmentKind('SIMPLE_LEFT', 7)
; |
725 static final AssignmentKind SIMPLE_RIGHT = new AssignmentKind('SIMPLE_RIGHT',
8); | 725 static final AssignmentKind SIMPLE_RIGHT = new AssignmentKind('SIMPLE_RIGHT',
8); |
726 static final AssignmentKind NONE = new AssignmentKind('NONE', 9); | 726 static final AssignmentKind NONE = new AssignmentKind('NONE', 9); |
727 static final List<AssignmentKind> values = [ | 727 static final List<AssignmentKind> values = [ |
728 BINARY, | 728 BINARY, |
729 COMPOUND_LEFT, | 729 COMPOUND_LEFT, |
730 COMPOUND_RIGHT, | 730 COMPOUND_RIGHT, |
731 POSTFIX_INC, | 731 POSTFIX_INC, |
732 PREFIX_DEC, | 732 PREFIX_DEC, |
733 PREFIX_INC, | 733 PREFIX_INC, |
734 PREFIX_NOT, | 734 PREFIX_NOT, |
735 SIMPLE_LEFT, | 735 SIMPLE_LEFT, |
736 SIMPLE_RIGHT, | 736 SIMPLE_RIGHT, |
737 NONE]; | 737 NONE]; |
738 | 738 AssignmentKind(String name, int ordinal) : super(name, ordinal); |
739 /// The name of this enum constant, as declared in the enum declaration. | |
740 final String name; | |
741 | |
742 /// The position in the enum declaration. | |
743 final int ordinal; | |
744 AssignmentKind(this.name, this.ordinal); | |
745 int compareTo(AssignmentKind other) => ordinal - other.ordinal; | |
746 int get hashCode => ordinal; | |
747 String toString() => name; | |
748 } | 739 } |
749 class WrapperKind implements Enum<WrapperKind> { | 740 class WrapperKind extends Enum<WrapperKind> { |
750 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0); | 741 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0); |
751 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1)
; | 742 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1)
; |
752 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2); | 743 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2); |
753 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3)
; | 744 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3)
; |
754 static final WrapperKind NONE = new WrapperKind('NONE', 4); | 745 static final WrapperKind NONE = new WrapperKind('NONE', 4); |
755 static final List<WrapperKind> values = [ | 746 static final List<WrapperKind> values = [ |
756 PREFIXED_LEFT, | 747 PREFIXED_LEFT, |
757 PREFIXED_RIGHT, | 748 PREFIXED_RIGHT, |
758 PROPERTY_LEFT, | 749 PROPERTY_LEFT, |
759 PROPERTY_RIGHT, | 750 PROPERTY_RIGHT, |
760 NONE]; | 751 NONE]; |
761 | 752 WrapperKind(String name, int ordinal) : super(name, ordinal); |
762 /// The name of this enum constant, as declared in the enum declaration. | |
763 final String name; | |
764 | |
765 /// The position in the enum declaration. | |
766 final int ordinal; | |
767 WrapperKind(this.name, this.ordinal); | |
768 int compareTo(WrapperKind other) => ordinal - other.ordinal; | |
769 int get hashCode => ordinal; | |
770 String toString() => name; | |
771 } | 753 } |
772 class BreadthFirstVisitorTest extends ParserTestCase { | 754 class BreadthFirstVisitorTest extends ParserTestCase { |
773 void testIt() { | 755 void testIt() { |
774 String source = EngineTestCase.createSource([ | 756 String source = EngineTestCase.createSource([ |
775 "class A {", | 757 "class A {", |
776 " bool get g => true;", | 758 " bool get g => true;", |
777 "}", | 759 "}", |
778 "class B {", | 760 "class B {", |
779 " int f() {", | 761 " int f() {", |
780 " num q() {", | 762 " num q() {", |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 Object value = getConstantValue("?"); | 825 Object value = getConstantValue("?"); |
844 JUnitTestCase.assertEquals(null, value); | 826 JUnitTestCase.assertEquals(null, value); |
845 } | 827 } |
846 void fail_identifier_typeVariable() { | 828 void fail_identifier_typeVariable() { |
847 Object value = getConstantValue("?"); | 829 Object value = getConstantValue("?"); |
848 JUnitTestCase.assertEquals(null, value); | 830 JUnitTestCase.assertEquals(null, value); |
849 } | 831 } |
850 void test_binary_bitAnd() { | 832 void test_binary_bitAnd() { |
851 Object value = getConstantValue("74 & 42"); | 833 Object value = getConstantValue("74 & 42"); |
852 EngineTestCase.assertInstanceOf(int, value); | 834 EngineTestCase.assertInstanceOf(int, value); |
853 JUnitTestCase.assertEquals(74 & 42, ((value as int))); | 835 JUnitTestCase.assertEquals(74 & 42, value as int); |
854 } | 836 } |
855 void test_binary_bitOr() { | 837 void test_binary_bitOr() { |
856 Object value = getConstantValue("74 | 42"); | 838 Object value = getConstantValue("74 | 42"); |
857 EngineTestCase.assertInstanceOf(int, value); | 839 EngineTestCase.assertInstanceOf(int, value); |
858 JUnitTestCase.assertEquals(74 | 42, ((value as int))); | 840 JUnitTestCase.assertEquals(74 | 42, value as int); |
859 } | 841 } |
860 void test_binary_bitXor() { | 842 void test_binary_bitXor() { |
861 Object value = getConstantValue("74 ^ 42"); | 843 Object value = getConstantValue("74 ^ 42"); |
862 EngineTestCase.assertInstanceOf(int, value); | 844 EngineTestCase.assertInstanceOf(int, value); |
863 JUnitTestCase.assertEquals(74 ^ 42, ((value as int))); | 845 JUnitTestCase.assertEquals(74 ^ 42, value as int); |
864 } | 846 } |
865 void test_binary_divide_double() { | 847 void test_binary_divide_double() { |
866 Object value = getConstantValue("3.2 / 2.3"); | 848 Object value = getConstantValue("3.2 / 2.3"); |
867 EngineTestCase.assertInstanceOf(double, value); | 849 EngineTestCase.assertInstanceOf(double, value); |
868 JUnitTestCase.assertEquals(3.2 / 2.3, ((value as double))); | 850 JUnitTestCase.assertEquals(3.2 / 2.3, value as double); |
869 } | 851 } |
870 void test_binary_divide_integer() { | 852 void test_binary_divide_integer() { |
871 Object value = getConstantValue("3 / 2"); | 853 Object value = getConstantValue("3 / 2"); |
872 EngineTestCase.assertInstanceOf(int, value); | 854 EngineTestCase.assertInstanceOf(int, value); |
873 JUnitTestCase.assertEquals(1, ((value as int))); | 855 JUnitTestCase.assertEquals(1, value as int); |
874 } | 856 } |
875 void test_binary_equal_boolean() { | 857 void test_binary_equal_boolean() { |
876 Object value = getConstantValue("true == false"); | 858 Object value = getConstantValue("true == false"); |
877 JUnitTestCase.assertEquals(false, value); | 859 JUnitTestCase.assertEquals(false, value); |
878 } | 860 } |
879 void test_binary_equal_integer() { | 861 void test_binary_equal_integer() { |
880 Object value = getConstantValue("2 == 3"); | 862 Object value = getConstantValue("2 == 3"); |
881 JUnitTestCase.assertEquals(false, value); | 863 JUnitTestCase.assertEquals(false, value); |
882 } | 864 } |
883 void test_binary_equal_invalidLeft() { | 865 void test_binary_equal_invalidLeft() { |
(...skipping 12 matching lines...) Expand all Loading... |
896 Object value = getConstantValue("2 > 3"); | 878 Object value = getConstantValue("2 > 3"); |
897 JUnitTestCase.assertEquals(false, value); | 879 JUnitTestCase.assertEquals(false, value); |
898 } | 880 } |
899 void test_binary_greaterThanOrEqual() { | 881 void test_binary_greaterThanOrEqual() { |
900 Object value = getConstantValue("2 >= 3"); | 882 Object value = getConstantValue("2 >= 3"); |
901 JUnitTestCase.assertEquals(false, value); | 883 JUnitTestCase.assertEquals(false, value); |
902 } | 884 } |
903 void test_binary_leftShift() { | 885 void test_binary_leftShift() { |
904 Object value = getConstantValue("16 << 2"); | 886 Object value = getConstantValue("16 << 2"); |
905 EngineTestCase.assertInstanceOf(int, value); | 887 EngineTestCase.assertInstanceOf(int, value); |
906 JUnitTestCase.assertEquals(64, ((value as int))); | 888 JUnitTestCase.assertEquals(64, value as int); |
907 } | 889 } |
908 void test_binary_lessThan() { | 890 void test_binary_lessThan() { |
909 Object value = getConstantValue("2 < 3"); | 891 Object value = getConstantValue("2 < 3"); |
910 JUnitTestCase.assertEquals(true, value); | 892 JUnitTestCase.assertEquals(true, value); |
911 } | 893 } |
912 void test_binary_lessThanOrEqual() { | 894 void test_binary_lessThanOrEqual() { |
913 Object value = getConstantValue("2 <= 3"); | 895 Object value = getConstantValue("2 <= 3"); |
914 JUnitTestCase.assertEquals(true, value); | 896 JUnitTestCase.assertEquals(true, value); |
915 } | 897 } |
916 void test_binary_logicalAnd() { | 898 void test_binary_logicalAnd() { |
917 Object value = getConstantValue("true && false"); | 899 Object value = getConstantValue("true && false"); |
918 JUnitTestCase.assertEquals(false, value); | 900 JUnitTestCase.assertEquals(false, value); |
919 } | 901 } |
920 void test_binary_logicalOr() { | 902 void test_binary_logicalOr() { |
921 Object value = getConstantValue("true || false"); | 903 Object value = getConstantValue("true || false"); |
922 JUnitTestCase.assertEquals(true, value); | 904 JUnitTestCase.assertEquals(true, value); |
923 } | 905 } |
924 void test_binary_minus_double() { | 906 void test_binary_minus_double() { |
925 Object value = getConstantValue("3.2 - 2.3"); | 907 Object value = getConstantValue("3.2 - 2.3"); |
926 EngineTestCase.assertInstanceOf(double, value); | 908 EngineTestCase.assertInstanceOf(double, value); |
927 JUnitTestCase.assertEquals(3.2 - 2.3, ((value as double))); | 909 JUnitTestCase.assertEquals(3.2 - 2.3, value as double); |
928 } | 910 } |
929 void test_binary_minus_integer() { | 911 void test_binary_minus_integer() { |
930 Object value = getConstantValue("3 - 2"); | 912 Object value = getConstantValue("3 - 2"); |
931 EngineTestCase.assertInstanceOf(int, value); | 913 EngineTestCase.assertInstanceOf(int, value); |
932 JUnitTestCase.assertEquals(1, ((value as int))); | 914 JUnitTestCase.assertEquals(1, value as int); |
933 } | 915 } |
934 void test_binary_notEqual_boolean() { | 916 void test_binary_notEqual_boolean() { |
935 Object value = getConstantValue("true != false"); | 917 Object value = getConstantValue("true != false"); |
936 JUnitTestCase.assertEquals(true, value); | 918 JUnitTestCase.assertEquals(true, value); |
937 } | 919 } |
938 void test_binary_notEqual_integer() { | 920 void test_binary_notEqual_integer() { |
939 Object value = getConstantValue("2 != 3"); | 921 Object value = getConstantValue("2 != 3"); |
940 JUnitTestCase.assertEquals(true, value); | 922 JUnitTestCase.assertEquals(true, value); |
941 } | 923 } |
942 void test_binary_notEqual_invalidLeft() { | 924 void test_binary_notEqual_invalidLeft() { |
943 Object value = getConstantValue("a != 3"); | 925 Object value = getConstantValue("a != 3"); |
944 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); | 926 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); |
945 } | 927 } |
946 void test_binary_notEqual_invalidRight() { | 928 void test_binary_notEqual_invalidRight() { |
947 Object value = getConstantValue("2 != a"); | 929 Object value = getConstantValue("2 != a"); |
948 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); | 930 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); |
949 } | 931 } |
950 void test_binary_notEqual_string() { | 932 void test_binary_notEqual_string() { |
951 Object value = getConstantValue("'a' != 'b'"); | 933 Object value = getConstantValue("'a' != 'b'"); |
952 JUnitTestCase.assertEquals(true, value); | 934 JUnitTestCase.assertEquals(true, value); |
953 } | 935 } |
954 void test_binary_plus_double() { | 936 void test_binary_plus_double() { |
955 Object value = getConstantValue("2.3 + 3.2"); | 937 Object value = getConstantValue("2.3 + 3.2"); |
956 EngineTestCase.assertInstanceOf(double, value); | 938 EngineTestCase.assertInstanceOf(double, value); |
957 JUnitTestCase.assertEquals(2.3 + 3.2, ((value as double))); | 939 JUnitTestCase.assertEquals(2.3 + 3.2, value as double); |
958 } | 940 } |
959 void test_binary_plus_integer() { | 941 void test_binary_plus_integer() { |
960 Object value = getConstantValue("2 + 3"); | 942 Object value = getConstantValue("2 + 3"); |
961 EngineTestCase.assertInstanceOf(int, value); | 943 EngineTestCase.assertInstanceOf(int, value); |
962 JUnitTestCase.assertEquals(5, ((value as int))); | 944 JUnitTestCase.assertEquals(5, value as int); |
963 } | 945 } |
964 void test_binary_remainder_double() { | 946 void test_binary_remainder_double() { |
965 Object value = getConstantValue("3.2 % 2.3"); | 947 Object value = getConstantValue("3.2 % 2.3"); |
966 EngineTestCase.assertInstanceOf(double, value); | 948 EngineTestCase.assertInstanceOf(double, value); |
967 JUnitTestCase.assertEquals(3.2 % 2.3, ((value as double))); | 949 JUnitTestCase.assertEquals(3.2 % 2.3, value as double); |
968 } | 950 } |
969 void test_binary_remainder_integer() { | 951 void test_binary_remainder_integer() { |
970 Object value = getConstantValue("8 % 3"); | 952 Object value = getConstantValue("8 % 3"); |
971 EngineTestCase.assertInstanceOf(int, value); | 953 EngineTestCase.assertInstanceOf(int, value); |
972 JUnitTestCase.assertEquals(2, ((value as int))); | 954 JUnitTestCase.assertEquals(2, value as int); |
973 } | 955 } |
974 void test_binary_rightShift() { | 956 void test_binary_rightShift() { |
975 Object value = getConstantValue("64 >> 2"); | 957 Object value = getConstantValue("64 >> 2"); |
976 EngineTestCase.assertInstanceOf(int, value); | 958 EngineTestCase.assertInstanceOf(int, value); |
977 JUnitTestCase.assertEquals(16, ((value as int))); | 959 JUnitTestCase.assertEquals(16, value as int); |
978 } | 960 } |
979 void test_binary_times_double() { | 961 void test_binary_times_double() { |
980 Object value = getConstantValue("2.3 * 3.2"); | 962 Object value = getConstantValue("2.3 * 3.2"); |
981 EngineTestCase.assertInstanceOf(double, value); | 963 EngineTestCase.assertInstanceOf(double, value); |
982 JUnitTestCase.assertEquals(2.3 * 3.2, ((value as double))); | 964 JUnitTestCase.assertEquals(2.3 * 3.2, value as double); |
983 } | 965 } |
984 void test_binary_times_integer() { | 966 void test_binary_times_integer() { |
985 Object value = getConstantValue("2 * 3"); | 967 Object value = getConstantValue("2 * 3"); |
986 EngineTestCase.assertInstanceOf(int, value); | 968 EngineTestCase.assertInstanceOf(int, value); |
987 JUnitTestCase.assertEquals(6, ((value as int))); | 969 JUnitTestCase.assertEquals(6, value as int); |
988 } | 970 } |
989 void test_binary_truncatingDivide_double() { | 971 void test_binary_truncatingDivide_double() { |
990 Object value = getConstantValue("3.2 ~/ 2.3"); | 972 Object value = getConstantValue("3.2 ~/ 2.3"); |
991 EngineTestCase.assertInstanceOf(int, value); | 973 EngineTestCase.assertInstanceOf(int, value); |
992 JUnitTestCase.assertEquals(1, ((value as int))); | 974 JUnitTestCase.assertEquals(1, value as int); |
993 } | 975 } |
994 void test_binary_truncatingDivide_integer() { | 976 void test_binary_truncatingDivide_integer() { |
995 Object value = getConstantValue("10 ~/ 3"); | 977 Object value = getConstantValue("10 ~/ 3"); |
996 EngineTestCase.assertInstanceOf(int, value); | 978 EngineTestCase.assertInstanceOf(int, value); |
997 JUnitTestCase.assertEquals(3, ((value as int))); | 979 JUnitTestCase.assertEquals(3, value as int); |
998 } | 980 } |
999 void test_literal_boolean_false() { | 981 void test_literal_boolean_false() { |
1000 Object value = getConstantValue("false"); | 982 Object value = getConstantValue("false"); |
1001 JUnitTestCase.assertEquals(false, value); | 983 JUnitTestCase.assertEquals(false, value); |
1002 } | 984 } |
1003 void test_literal_boolean_true() { | 985 void test_literal_boolean_true() { |
1004 Object value = getConstantValue("true"); | 986 Object value = getConstantValue("true"); |
1005 JUnitTestCase.assertEquals(true, value); | 987 JUnitTestCase.assertEquals(true, value); |
1006 } | 988 } |
1007 void test_literal_list() { | 989 void test_literal_list() { |
1008 Object value = getConstantValue("['a', 'b', 'c']"); | 990 Object value = getConstantValue("['a', 'b', 'c']"); |
1009 EngineTestCase.assertInstanceOf(List, value); | 991 EngineTestCase.assertInstanceOf(List, value); |
1010 List<Object> list = value as List<Object>; | 992 List list = value as List; |
1011 JUnitTestCase.assertEquals(3, list.length); | 993 JUnitTestCase.assertEquals(3, list.length); |
1012 JUnitTestCase.assertEquals("a", list[0]); | 994 JUnitTestCase.assertEquals("a", list[0]); |
1013 JUnitTestCase.assertEquals("b", list[1]); | 995 JUnitTestCase.assertEquals("b", list[1]); |
1014 JUnitTestCase.assertEquals("c", list[2]); | 996 JUnitTestCase.assertEquals("c", list[2]); |
1015 } | 997 } |
1016 void test_literal_map() { | 998 void test_literal_map() { |
1017 Object value = getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}"); | 999 Object value = getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}"); |
1018 EngineTestCase.assertInstanceOf(Map, value); | 1000 EngineTestCase.assertInstanceOf(Map, value); |
1019 Map<Object, Object> map = value as Map<Object, Object>; | 1001 Map map = value as Map; |
1020 JUnitTestCase.assertEquals(3, map.length); | 1002 JUnitTestCase.assertEquals(3, map.length); |
1021 JUnitTestCase.assertEquals("m", map["a"]); | 1003 JUnitTestCase.assertEquals("m", map["a"]); |
1022 JUnitTestCase.assertEquals("n", map["b"]); | 1004 JUnitTestCase.assertEquals("n", map["b"]); |
1023 JUnitTestCase.assertEquals("o", map["c"]); | 1005 JUnitTestCase.assertEquals("o", map["c"]); |
1024 } | 1006 } |
1025 void test_literal_null() { | 1007 void test_literal_null() { |
1026 Object value = getConstantValue("null"); | 1008 Object value = getConstantValue("null"); |
1027 JUnitTestCase.assertEquals(null, value); | 1009 JUnitTestCase.assertEquals(null, value); |
1028 } | 1010 } |
1029 void test_literal_number_double() { | 1011 void test_literal_number_double() { |
1030 Object value = getConstantValue("3.45"); | 1012 Object value = getConstantValue("3.45"); |
1031 EngineTestCase.assertInstanceOf(double, value); | 1013 EngineTestCase.assertInstanceOf(double, value); |
1032 JUnitTestCase.assertEquals(3.45, ((value as double))); | 1014 JUnitTestCase.assertEquals(3.45, value as double); |
1033 } | 1015 } |
1034 void test_literal_number_integer() { | 1016 void test_literal_number_integer() { |
1035 Object value = getConstantValue("42"); | 1017 Object value = getConstantValue("42"); |
1036 EngineTestCase.assertInstanceOf(int, value); | 1018 EngineTestCase.assertInstanceOf(int, value); |
1037 JUnitTestCase.assertEquals(42, ((value as int))); | 1019 JUnitTestCase.assertEquals(42, value as int); |
1038 } | 1020 } |
1039 void test_literal_string_adjacent() { | 1021 void test_literal_string_adjacent() { |
1040 Object value = getConstantValue("'abc' 'def'"); | 1022 Object value = getConstantValue("'abc' 'def'"); |
1041 JUnitTestCase.assertEquals("abcdef", value); | 1023 JUnitTestCase.assertEquals("abcdef", value); |
1042 } | 1024 } |
1043 void test_literal_string_interpolation_invalid() { | 1025 void test_literal_string_interpolation_invalid() { |
1044 Object value = getConstantValue("'a\${f()}c'"); | 1026 Object value = getConstantValue("'a\${f()}c'"); |
1045 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); | 1027 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); |
1046 } | 1028 } |
1047 void test_literal_string_interpolation_valid() { | 1029 void test_literal_string_interpolation_valid() { |
1048 Object value = getConstantValue("'a\${3}c'"); | 1030 Object value = getConstantValue("'a\${3}c'"); |
1049 JUnitTestCase.assertEquals("a3c", value); | 1031 JUnitTestCase.assertEquals("a3c", value); |
1050 } | 1032 } |
1051 void test_literal_string_simple() { | 1033 void test_literal_string_simple() { |
1052 Object value = getConstantValue("'abc'"); | 1034 Object value = getConstantValue("'abc'"); |
1053 JUnitTestCase.assertEquals("abc", value); | 1035 JUnitTestCase.assertEquals("abc", value); |
1054 } | 1036 } |
1055 void test_parenthesizedExpression() { | 1037 void test_parenthesizedExpression() { |
1056 Object value = getConstantValue("('a')"); | 1038 Object value = getConstantValue("('a')"); |
1057 JUnitTestCase.assertEquals("a", value); | 1039 JUnitTestCase.assertEquals("a", value); |
1058 } | 1040 } |
1059 void test_unary_bitNot() { | 1041 void test_unary_bitNot() { |
1060 Object value = getConstantValue("~42"); | 1042 Object value = getConstantValue("~42"); |
1061 EngineTestCase.assertInstanceOf(int, value); | 1043 EngineTestCase.assertInstanceOf(int, value); |
1062 JUnitTestCase.assertEquals(~42, ((value as int))); | 1044 JUnitTestCase.assertEquals(~42, value as int); |
1063 } | 1045 } |
1064 void test_unary_logicalNot() { | 1046 void test_unary_logicalNot() { |
1065 Object value = getConstantValue("!true"); | 1047 Object value = getConstantValue("!true"); |
1066 JUnitTestCase.assertEquals(false, value); | 1048 JUnitTestCase.assertEquals(false, value); |
1067 } | 1049 } |
1068 void test_unary_negated_double() { | 1050 void test_unary_negated_double() { |
1069 Object value = getConstantValue("-42.3"); | 1051 Object value = getConstantValue("-42.3"); |
1070 EngineTestCase.assertInstanceOf(double, value); | 1052 EngineTestCase.assertInstanceOf(double, value); |
1071 JUnitTestCase.assertEquals(-42.3, ((value as double))); | 1053 JUnitTestCase.assertEquals(-42.3, value as double); |
1072 } | 1054 } |
1073 void test_unary_negated_integer() { | 1055 void test_unary_negated_integer() { |
1074 Object value = getConstantValue("-42"); | 1056 Object value = getConstantValue("-42"); |
1075 EngineTestCase.assertInstanceOf(int, value); | 1057 EngineTestCase.assertInstanceOf(int, value); |
1076 JUnitTestCase.assertEquals(-42, ((value as int))); | 1058 JUnitTestCase.assertEquals(-42, value as int); |
1077 } | 1059 } |
1078 Object getConstantValue(String source) => ParserTestCase.parseExpression(sourc
e, []).accept(new ConstantEvaluator()); | 1060 Object getConstantValue(String source) => ParserTestCase.parseExpression(sourc
e, []).accept(new ConstantEvaluator()); |
1079 static dartSuite() { | 1061 static dartSuite() { |
1080 _ut.group('ConstantEvaluatorTest', () { | 1062 _ut.group('ConstantEvaluatorTest', () { |
1081 _ut.test('test_binary_bitAnd', () { | 1063 _ut.test('test_binary_bitAnd', () { |
1082 final __test = new ConstantEvaluatorTest(); | 1064 final __test = new ConstantEvaluatorTest(); |
1083 runJUnitTest(__test, __test.test_binary_bitAnd); | 1065 runJUnitTest(__test, __test.test_binary_bitAnd); |
1084 }); | 1066 }); |
1085 _ut.test('test_binary_bitOr', () { | 1067 _ut.test('test_binary_bitOr', () { |
1086 final __test = new ConstantEvaluatorTest(); | 1068 final __test = new ConstantEvaluatorTest(); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
c"), ASTFactory.integer(3))])); | 1619 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
c"), ASTFactory.integer(3))])); |
1638 } | 1620 } |
1639 void test_visitFormalParameterList_rrpp() { | 1621 void test_visitFormalParameterList_rrpp() { |
1640 assertSource("(a, b, [c = 3, d = 4])", ASTFactory.formalParameterList([ | 1622 assertSource("(a, b, [c = 3, d = 4])", ASTFactory.formalParameterList([ |
1641 ASTFactory.simpleFormalParameter3("a"), | 1623 ASTFactory.simpleFormalParameter3("a"), |
1642 ASTFactory.simpleFormalParameter3("b"), | 1624 ASTFactory.simpleFormalParameter3("b"), |
1643 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
c"), ASTFactory.integer(3)), | 1625 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
c"), ASTFactory.integer(3)), |
1644 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
d"), ASTFactory.integer(4))])); | 1626 ASTFactory.positionalFormalParameter(ASTFactory.simpleFormalParameter3("
d"), ASTFactory.integer(4))])); |
1645 } | 1627 } |
1646 void test_visitForStatement_c() { | 1628 void test_visitForStatement_c() { |
1647 assertSource("for (; c;) {}", ASTFactory.forStatement((null as Expression),
ASTFactory.identifier3("c"), null, ASTFactory.block([]))); | 1629 assertSource("for (; c;) {}", ASTFactory.forStatement(null as Expression, AS
TFactory.identifier3("c"), null, ASTFactory.block([]))); |
1648 } | 1630 } |
1649 void test_visitForStatement_cu() { | 1631 void test_visitForStatement_cu() { |
1650 assertSource("for (; c; u) {}", ASTFactory.forStatement((null as Expression)
, ASTFactory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3("u") as
Expression)]), ASTFactory.block([]))); | 1632 assertSource("for (; c; u) {}", ASTFactory.forStatement(null as Expression,
ASTFactory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3("u") as Ex
pression)]), ASTFactory.block([]))); |
1651 } | 1633 } |
1652 void test_visitForStatement_e() { | 1634 void test_visitForStatement_e() { |
1653 assertSource("for (e;;) {}", ASTFactory.forStatement(ASTFactory.identifier3(
"e"), null, null, ASTFactory.block([]))); | 1635 assertSource("for (e;;) {}", ASTFactory.forStatement(ASTFactory.identifier3(
"e"), null, null, ASTFactory.block([]))); |
1654 } | 1636 } |
1655 void test_visitForStatement_ec() { | 1637 void test_visitForStatement_ec() { |
1656 assertSource("for (e; c;) {}", ASTFactory.forStatement(ASTFactory.identifier
3("e"), ASTFactory.identifier3("c"), null, ASTFactory.block([]))); | 1638 assertSource("for (e; c;) {}", ASTFactory.forStatement(ASTFactory.identifier
3("e"), ASTFactory.identifier3("c"), null, ASTFactory.block([]))); |
1657 } | 1639 } |
1658 void test_visitForStatement_ecu() { | 1640 void test_visitForStatement_ecu() { |
1659 assertSource("for (e; c; u) {}", ASTFactory.forStatement(ASTFactory.identifi
er3("e"), ASTFactory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3(
"u") as Expression)]), ASTFactory.block([]))); | 1641 assertSource("for (e; c; u) {}", ASTFactory.forStatement(ASTFactory.identifi
er3("e"), ASTFactory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3(
"u") as Expression)]), ASTFactory.block([]))); |
1660 } | 1642 } |
1661 void test_visitForStatement_eu() { | 1643 void test_visitForStatement_eu() { |
1662 assertSource("for (e;; u) {}", ASTFactory.forStatement(ASTFactory.identifier
3("e"), null, ASTFactory.list([(ASTFactory.identifier3("u") as Expression)]), AS
TFactory.block([]))); | 1644 assertSource("for (e;; u) {}", ASTFactory.forStatement(ASTFactory.identifier
3("e"), null, ASTFactory.list([(ASTFactory.identifier3("u") as Expression)]), AS
TFactory.block([]))); |
1663 } | 1645 } |
1664 void test_visitForStatement_i() { | 1646 void test_visitForStatement_i() { |
1665 assertSource("for (var i;;) {}", ASTFactory.forStatement2(ASTFactory.variabl
eDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), null, nul
l, ASTFactory.block([]))); | 1647 assertSource("for (var i;;) {}", ASTFactory.forStatement2(ASTFactory.variabl
eDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), null, nul
l, ASTFactory.block([]))); |
1666 } | 1648 } |
1667 void test_visitForStatement_ic() { | 1649 void test_visitForStatement_ic() { |
1668 assertSource("for (var i; c;) {}", ASTFactory.forStatement2(ASTFactory.varia
bleDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), ASTFact
ory.identifier3("c"), null, ASTFactory.block([]))); | 1650 assertSource("for (var i; c;) {}", ASTFactory.forStatement2(ASTFactory.varia
bleDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), ASTFact
ory.identifier3("c"), null, ASTFactory.block([]))); |
1669 } | 1651 } |
1670 void test_visitForStatement_icu() { | 1652 void test_visitForStatement_icu() { |
1671 assertSource("for (var i; c; u) {}", ASTFactory.forStatement2(ASTFactory.var
iableDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), ASTFa
ctory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3("u") as Express
ion)]), ASTFactory.block([]))); | 1653 assertSource("for (var i; c; u) {}", ASTFactory.forStatement2(ASTFactory.var
iableDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), ASTFa
ctory.identifier3("c"), ASTFactory.list([(ASTFactory.identifier3("u") as Express
ion)]), ASTFactory.block([]))); |
1672 } | 1654 } |
1673 void test_visitForStatement_iu() { | 1655 void test_visitForStatement_iu() { |
1674 assertSource("for (var i;; u) {}", ASTFactory.forStatement2(ASTFactory.varia
bleDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), null, A
STFactory.list([(ASTFactory.identifier3("u") as Expression)]), ASTFactory.block(
[]))); | 1656 assertSource("for (var i;; u) {}", ASTFactory.forStatement2(ASTFactory.varia
bleDeclarationList2(Keyword.VAR, [ASTFactory.variableDeclaration("i")]), null, A
STFactory.list([(ASTFactory.identifier3("u") as Expression)]), ASTFactory.block(
[]))); |
1675 } | 1657 } |
1676 void test_visitForStatement_u() { | 1658 void test_visitForStatement_u() { |
1677 assertSource("for (;; u) {}", ASTFactory.forStatement((null as Expression),
null, ASTFactory.list([(ASTFactory.identifier3("u") as Expression)]), ASTFactory
.block([]))); | 1659 assertSource("for (;; u) {}", ASTFactory.forStatement(null as Expression, nu
ll, ASTFactory.list([(ASTFactory.identifier3("u") as Expression)]), ASTFactory.b
lock([]))); |
1678 } | 1660 } |
1679 void test_visitFunctionDeclaration_getter() { | 1661 void test_visitFunctionDeclaration_getter() { |
1680 assertSource("get f() {}", ASTFactory.functionDeclaration(null, Keyword.GET,
"f", ASTFactory.functionExpression())); | 1662 assertSource("get f() {}", ASTFactory.functionDeclaration(null, Keyword.GET,
"f", ASTFactory.functionExpression())); |
1681 } | 1663 } |
1682 void test_visitFunctionDeclaration_normal() { | 1664 void test_visitFunctionDeclaration_normal() { |
1683 assertSource("f() {}", ASTFactory.functionDeclaration(null, null, "f", ASTFa
ctory.functionExpression())); | 1665 assertSource("f() {}", ASTFactory.functionDeclaration(null, null, "f", ASTFa
ctory.functionExpression())); |
1684 } | 1666 } |
1685 void test_visitFunctionDeclaration_setter() { | 1667 void test_visitFunctionDeclaration_setter() { |
1686 assertSource("set f() {}", ASTFactory.functionDeclaration(null, Keyword.SET,
"f", ASTFactory.functionExpression())); | 1668 assertSource("set f() {}", ASTFactory.functionDeclaration(null, Keyword.SET,
"f", ASTFactory.functionExpression())); |
1687 } | 1669 } |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 } | 3096 } |
3115 main() { | 3097 main() { |
3116 ConstantEvaluatorTest.dartSuite(); | 3098 ConstantEvaluatorTest.dartSuite(); |
3117 NodeLocatorTest.dartSuite(); | 3099 NodeLocatorTest.dartSuite(); |
3118 ToSourceVisitorTest.dartSuite(); | 3100 ToSourceVisitorTest.dartSuite(); |
3119 BreadthFirstVisitorTest.dartSuite(); | 3101 BreadthFirstVisitorTest.dartSuite(); |
3120 IndexExpressionTest.dartSuite(); | 3102 IndexExpressionTest.dartSuite(); |
3121 SimpleIdentifierTest.dartSuite(); | 3103 SimpleIdentifierTest.dartSuite(); |
3122 VariableDeclarationTest.dartSuite(); | 3104 VariableDeclarationTest.dartSuite(); |
3123 } | 3105 } |
OLD | NEW |