##// END OF EJS Templates
revset: test current behavior of addset class...
Yuya Nishihara -
r25024:263bbed1 default
parent child Browse files
Show More
@@ -2944,6 +2944,64 class addset(abstractsmartset):
2944 If the ascending attribute is set, that means the two structures are
2944 If the ascending attribute is set, that means the two structures are
2945 ordered in either an ascending or descending way. Therefore, we can add
2945 ordered in either an ascending or descending way. Therefore, we can add
2946 them maintaining the order by iterating over both at the same time
2946 them maintaining the order by iterating over both at the same time
2947
2948 >>> xs = baseset([0, 3, 2])
2949 >>> ys = baseset([5, 2, 4])
2950
2951 >>> rs = addset(xs, ys)
2952 >>> bool(rs), 0 in rs, 1 in rs, 5 in rs, rs.first(), rs.last()
2953 (True, True, False, True, 0, 4)
2954 >>> rs = addset(xs, baseset([]))
2955 >>> bool(rs), 0 in rs, 1 in rs, rs.first(), rs.last()
2956 (True, True, False, 0, 2)
2957 >>> rs = addset(baseset([]), baseset([]))
2958 >>> bool(rs), 0 in rs, rs.first(), rs.last()
2959 (False, False, None, None)
2960
2961 iterate unsorted:
2962 >>> rs = addset(xs, ys)
2963 >>> [x for x in rs] # without _genlist
2964 [0, 3, 2, 5, 4]
2965 >>> assert not rs._genlist
2966 >>> len(rs)
2967 5
2968 >>> [x for x in rs] # with _genlist
2969 [0, 3, 2, 5, 4]
2970 >>> assert rs._genlist
2971
2972 iterate ascending:
2973 >>> rs = addset(xs, ys, ascending=True)
2974 >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist
2975 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
2976 >>> assert not rs._asclist
2977 >>> len(rs) # BROKEN
2978 6
2979 >>> [x for x in rs], [x for x in rs.fastasc()] # BROKEN with _asclist
2980 ([0, 2, 2, 3, 4, 5], [0, 2, 2, 3, 4, 5])
2981 >>> assert rs._asclist
2982
2983 iterate descending:
2984 >>> rs = addset(xs, ys, ascending=False)
2985 >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist
2986 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
2987 >>> assert not rs._asclist
2988 >>> len(rs) # BROKEN
2989 6
2990 >>> [x for x in rs], [x for x in rs.fastdesc()] # BROKEN with _asclist
2991 ([5, 4, 3, 2, 2, 0], [5, 4, 3, 2, 2, 0])
2992 >>> assert rs._asclist
2993
2994 iterate ascending without fastasc:
2995 >>> rs = addset(xs, generatorset(ys), ascending=True)
2996 >>> assert rs.fastasc is None
2997 >>> [x for x in rs] # BROKEN
2998 [0, 2, 2, 3, 4, 5]
2999
3000 iterate descending without fastdesc:
3001 >>> rs = addset(generatorset(xs), ys, ascending=False)
3002 >>> assert rs.fastdesc is None
3003 >>> [x for x in rs] # BROKEN
3004 [5, 4, 3, 2, 2, 0]
2947 """
3005 """
2948 def __init__(self, revs1, revs2, ascending=None):
3006 def __init__(self, revs1, revs2, ascending=None):
2949 self._r1 = revs1
3007 self._r1 = revs1
@@ -833,6 +833,54 test that `or` operation combines elemen
833 4
833 4
834 5
834 5
835
835
836 test that `or` operation skips duplicated revisions from right-hand side
837
838 $ try 'reverse(1::5) or ancestors(4)'
839 (or
840 (func
841 ('symbol', 'reverse')
842 (dagrange
843 ('symbol', '1')
844 ('symbol', '5')))
845 (func
846 ('symbol', 'ancestors')
847 ('symbol', '4')))
848 * set:
849 <addset
850 <baseset [5, 3, 1]>,
851 <filteredset
852 <filteredset
853 <fullreposet+ 0:9>>>>
854 5
855 3
856 1
857 0
858 2
859 4
860 $ try 'sort(ancestors(4) or reverse(1::5))'
861 (func
862 ('symbol', 'sort')
863 (or
864 (func
865 ('symbol', 'ancestors')
866 ('symbol', '4'))
867 (func
868 ('symbol', 'reverse')
869 (dagrange
870 ('symbol', '1')
871 ('symbol', '5')))))
872 * set:
873 <addset+
874 <generatorset+>,
875 <filteredset
876 <baseset [5, 3, 1]>>>
877 0
878 1
879 2
880 3
881 4
882 5
883
836 check that conversion to only works
884 check that conversion to only works
837 $ try --optimize '::3 - ::1'
885 $ try --optimize '::3 - ::1'
838 (minus
886 (minus
General Comments 0
You need to be logged in to leave comments. Login now