Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Prasetya, S.W.B. (Wishnu)
t3
Commits
78d2fc1d
Commit
78d2fc1d
authored
Jan 25, 2019
by
ISWB Prasetya
Browse files
making G2 generator to reuse more from pool as params for target-method
parent
f5cbef34
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2SuiteGen.java
View file @
78d2fc1d
...
...
@@ -72,6 +72,7 @@ public class G2SuiteGen {
public
Pool
pool
;
private
G2ValueMG
gen2vmg
;
private
Generator
<
PARAM
,
STEP
>
valueMG
;
private
Generator
<
PARAM
,
STEP
>
valueMG_with_tendency_to_reuse_objs
;
public
StaticInfo
staticInfo
=
null
;
public
CodeCoverage
codeCoverage
=
null
;
...
...
@@ -193,6 +194,7 @@ public class G2SuiteGen {
resetSeededConstants
()
;
pool
=
gen2vmg
.
pool
;
valueMG
=
gen2vmg
.
valueMG
()
;
valueMG_with_tendency_to_reuse_objs
=
gen2vmg
.
valueMG_leaningTowardsReuseOldObjects
()
;
}
private
String
[]
seededSPrimitives
;
...
...
@@ -202,9 +204,9 @@ public class G2SuiteGen {
* below, and the list of instanceOf constants is cleared.
*/
public
void
resetSeededConstants
()
{
String
[]
seeded
=
{
"0"
,
"1"
,
"-1"
,
"2"
,
"
9
"
,
"10"
,
"0.0001"
,
"0.05"
,
"-0.05"
,
"<abc@com>"
,
"
<
www.
x.com
>"
,
"<2000-12-12>"
,
"<24:00:00>"
String
[]
seeded
=
{
"0"
,
"1"
,
"-1"
,
"2"
,
"
7
"
,
"10"
,
"0.0001"
,
"0.05"
,
"-0.05"
,
"2018"
,
"<X>"
,
"<joe>"
,
"<127.0.0.1>"
,
"<abc@com>"
,
"www.
w3.org
>"
,
"<2000-12-12>"
,
"<24:00:00>"
}
;
seededSPrimitives
=
seeded
;
gen2vmg
.
configureSeededSPrimitives
(
seededSPrimitives
);
...
...
@@ -582,7 +584,8 @@ public class G2SuiteGen {
addInstanceOfConstants
(
staticInfo
.
getInstanceOfClasses
(
m
))
;
}
T3SeqG
seqG
=
new
T3SeqG
(
pool
,
scope
,
maxNumberOfStepRetry
,
valueMG
)
;
//T3SeqG seqG = new T3SeqG(pool,scope,maxNumberOfStepRetry,valueMG) ;
T3SeqG
seqG
=
new
T3SeqG
(
pool
,
scope
,
maxNumberOfStepRetry
,
valueMG_with_tendency_to_reuse_objs
)
;
Generator
<
SEQ_RT_info
,
SEQ_RT_info
>
suffixgen
;
if
(
regressionMode
)
{
if
(
scope
.
mutators
.
contains
(
m
))
{
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2ValueMG.java
View file @
78d2fc1d
...
...
@@ -455,6 +455,33 @@ public class G2ValueMG {
return
g
;
}
/**
* This will construct the meta-generator to generate values; the generator will have
* higher probability to reuse objects from the pool.
*/
public
Generator
<
PARAM
,
STEP
>
valueMG_leaningTowardsReuseOldObjects
()
{
FUN
<
Generator
<
PARAM
,
STEP
>>
recGenerator
=
new
FUN
<
Generator
<
PARAM
,
STEP
>>()
;
Generator
<
PARAM
,
STEP
>
g
=
FirstOf
(
refgens
.
random
().
WithChance
(
0.4
),
nullgens
.
constant
().
WithChance
(
0.04
),
sprimitiveMG
(),
enumgens
.
random
(),
refgens
.
objectUnderTest
().
WithChance
(
0.4
),
refgens
.
objectUnderTestIfSubclass
().
WithChance
(
0.1
),
collectiongens
.
collectionlike
(
recGenerator
),
lambdagens
.
constlambdaMG
(
recGenerator
),
constructorgens
.
useConstructor
(
recGenerator
).
transformReq
(
P
->
remapPARAM_with_InstanceOfConstants
(
P
)).
WithChance
(
0.4
),
constructorgens
.
useConstructor
(
recGenerator
),
constructorgens
.
useCreationyMethod
(
recGenerator
).
transformReq
(
P
->
remapPARAM_with_InstanceOfConstants
(
P
)).
WithChance
(
0.4
),
constructorgens
.
useCreationyMethod
(
recGenerator
),
// if all the above fails.. then generate null
nullgens
.
defaulting
()
)
;
recGenerator
.
fun
=
g
;
return
g
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
String
.
class
.
isPrimitive
())
;
...
...
src/Sequenic/T3/Examples/Item.java
View file @
78d2fc1d
...
...
@@ -22,10 +22,23 @@ public class Item implements Serializable {
System
.
out
.
println
(
">>> incPrice "
+
x
)
;
price
+=
x
;
}
public
String
setCode
(
String
code
)
{
System
.
out
.
println
(
">>> setCode "
+
code
)
;
this
.
code
=
code
;
return
this
.
code
;
public
static
class
Code
{
String
code
;
public
Code
(
String
c
)
{
code
=
c
;
}
public
String
toString
()
{
return
"Code "
+
code
;
}
}
public
String
setCode
(
Code
c
)
{
System
.
out
.
println
(
">>> setCode "
+
c
.
code
)
;
this
.
code
=
c
.
code
;
return
this
.
code
;
}
public
boolean
checkzSameCode
(
Code
c
)
{
System
.
out
.
println
(
">>> checkzSameCode "
+
c
.
code
)
;
return
code
.
equals
(
c
.
code
)
;
}
public
String
getCode
()
{
System
.
out
.
println
(
">>> getCode "
)
;
return
code
;
...
...
src/Sequenic/T3/Generator/SeqAndSuite/SegmentG.java
View file @
78d2fc1d
...
...
@@ -91,19 +91,14 @@ public class SegmentG extends AbstractSeqGenerator {
Generator
<
SEQ_RT_info
,
STEP
>
methodMGxx
=
info
->
{
int
N
=
methods_
.
size
()
;
if
(
N
==
0
)
return
null
;
if
(
N
==
1
)
{
Method
M
=
methods_
.
get
(
0
)
;
Method
M
=
methods_
.
get
(
methodMGbase
.
rnd
.
nextInt
(
N
))
;
if
(
M
.
getName
().
startsWith
(
"set"
))
methods_
.
remove
(
M
)
;
else
{
Integer
M_cnt
=
counts
.
get
(
M
)
;
if
(
M_cnt
==
null
)
M_cnt
=
1
;
else
M_cnt
++
;
if
(
M_cnt
>=
2
)
methods_
.
remove
(
M
)
;
return
methodMGbase
.
select
(
M
).
generate
(
info
)
;
if
(
M_cnt
>=
2
)
methods_
.
remove
(
M
)
;
counts
.
put
(
M
,
M_cnt
)
;
}
// randomly select a method :
Method
M
=
methods_
.
get
(
methodMGbase
.
rnd
.
nextInt
(
N
))
;
Integer
M_cnt
=
counts
.
get
(
M
)
;
if
(
M_cnt
==
null
)
M_cnt
=
1
;
else
M_cnt
++
;
if
(
M_cnt
>=
2
)
methods_
.
remove
(
M
)
;
counts
.
put
(
M
,
M_cnt
)
;
return
methodMGbase
.
select
(
M
).
generate
(
info
)
;
}
;
...
...
src/Sequenic/T3/Generator/Value/REFMG.java
View file @
78d2fc1d
...
...
@@ -41,6 +41,7 @@ public class REFMG {
return
P
->
{
Integer
k
=
pool
.
rndGetIndex
(
P
.
ty
)
;
if
(
k
!=
null
)
{
System
.
out
.
println
(
"=== REUSING obj: "
+
pool
.
get
(
k
))
;
return
new
Maybe
(
new
REF
(
k
))
;
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment