summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/parallel-collections/IntOperators.scala
blob: 4a74b91da862084a48b7f973201682ce0bfeec05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package scala.collection.parallel.ops


import scala.collection.parallel._


trait IntOperators extends Operators[Int] {
  def reduceOperators = List(_ + _, _ * _, math.min(_, _), math.max(_, _), _ ^ _)
  def countPredicates = List(
    x => true,
    _ >= 0, _ < 0, _ < 50, _ < 500, _ < 5000, _ < 50000, _ % 2 == 0, _ == 99,
    x => x > 50 && x < 150,
    x => x > 350 && x < 550,
    x => (x > 1000 && x < 1500) || (x > 400 && x < 500)
  )
  def forallPredicates = List(_ >= 0, _ < 0, _ % 2 == 0, _ != 55, _ != 505, _ != 5005)
  def existsPredicates = List(_ >= 0, _ < 0, _ % 2 == 0, _ == 55, _ == 505, _ == 5005)
  def findPredicates = List(_ >= 0, _ % 2 == 0, _ < 0, _ == 50, _ == 500, _ == 5000)
  def mapFunctions = List(-_, math.abs(_), _ % 2, _ % 3, _ % 4, _ % 150, _ % 500)
  def partialMapFunctions = List({case x => -x}, { case 0 => -1; case x if x > 0 => x + 1}, {case x if x % 3 == 0 => x / 3})
  def flatMapFunctions = List(
    (n: Int) => if (n < 0) List() else if (n % 2 == 0) List(1, 2, 3) else List(4, 5, 6),
    (n: Int) => List[Int](),
    (n: Int) => if (n == 0) List(1, 2, 3, 4, 5) else if (n < 0) List(1, 2, 3) else List()
  )
  def filterPredicates = List(
    _ % 2 == 0, _ % 3 == 0,
    _ % 4 != 0, _ % 17 != 0,
    n => n > 50 && n < 100,
    _ >= 0, _ < 0, _ == 99,
    _ > 500, _ > 5000, _ > 50000,
    _ < 500, _ < 50, _ < -50, _ < -5e5,
    x => true, x => false,
    x => x % 53 == 0 && x % 17 == 0
  )
  def filterNotPredicates = filterPredicates
  def partitionPredicates = filterPredicates
  def takeWhilePredicates = List(
    _ != 50, _ != 500, _ != 5000, _ != 50000, _ % 2 == 0, _ % 3 == 1, _ % 47 != 0,
    _ < 100, _ < 1000, _ < 10000, _ < 0,
    _ < -100, _ < -1000, _ > -200, _ > -50,
    n => -90 < n && n < -10,
    n => 50 < n && n < 550,
    n => 5000 < n && n < 7500,
    n => -50 < n && n < 450
  )
  def dropWhilePredicates = takeWhilePredicates
  def spanPredicates = takeWhilePredicates
  def foldArguments = List(
    (0, _ + _),
    (1, _ * _),
    (Int.MinValue, math.max(_, _)),
    (Int.MaxValue, math.min(_, _))
  )
  def addAllTraversables = List(
    List[Int](),
    List(1),
    List(1, 2),
    List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
    Array.fill(1000)(1).toSeq
  )
  def newArray(sz: Int) = new Array[Int](sz)
  def groupByFunctions = List(
    _ % 2, _ % 3, _ % 5, _ % 10, _ % 154, _% 3217,
    _ * 2, _ + 1
  )
}


trait IntSeqOperators extends IntOperators with SeqOperators[Int] {
  def segmentLengthPredicates = List(
    _ % 2 == 0, _ > 0, _ >= 0, _ < 0, _ <= 0, _ > -5000, _ > 5000, _ % 541 != 0, _ < -50, _ > 500,
    n => -90 < n && n < -10, n => 500 < n && n < 1500
  )
  def indexWherePredicates = List(
    _ % 2 == 0, _ % 11 == 0, _ % 123 == 0, _ % 901 == 0,
    _ > 0, _ >= 0, _ < 0, _ <= 0,
    _ > 50, _ > 500, _ > 5000,
    _ < -10, _ < -100, _ < -1000,
    n => n > 50 && n < 100,
    n => n * n > 1000000 && n % 111 == 0
  )
  def lastIndexWherePredicates = List(
    _ % 2 == 0, _ % 17 == 0, _ % 314 == 0, _ % 1017 == 0,
    _ > 0, _ >= 0, _ < 0, _ <= 0,
    _ > 50, _ > 500, _ > 5000,
    _ < -20, _ < -200, _ < -2000,
    _ == 0,
    n => n > -40 && n < 40,
    n => n > -80 && n < -10,
    n => n > 110 && n < 150
  )
  def reverseMapFunctions = List(-_, n => n * n, _ + 1)
  def sameElementsSeqs = List(
    List[Int](),
    List(1),
    List(1, 2, 3, 4, 5, 6, 7, 8, 9),
    Array.fill(150)(1).toSeq,
    Array.fill(1000)(1).toSeq
  )
  def startEndSeqs = List(
    Nil,
    List(1),
    List(1, 2, 3, 4, 5),
    List(0, 1, 2, 3, 4, 5),
    List(4, 5, 6, 7, 8, 9, 10),
    List(4, 5, 6, 7, 8, 9, 0),
    List(-4, -3, -2, -1)
  )
}