Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
3aa5dbee
Commit
3aa5dbee
authored
4 years ago
by
Julien29121998
Browse files
Options
Downloads
Patches
Plain Diff
implements brg42 toNewcomer
parent
232c4480
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/local_augmentation_example.ex
+10
-0
10 additions, 0 deletions
lib/local_augmentation_example.ex
test/certification/augmentation/to_newcomer_test.exs
+44
-0
44 additions, 0 deletions
test/certification/augmentation/to_newcomer_test.exs
with
54 additions
and
0 deletions
lib/local_augmentation_example.ex
+
10
−
0
View file @
3aa5dbee
...
...
@@ -146,4 +146,14 @@ defmodule Index.Augmentation do
)
end
end
defmodule
CIndex
do
def
toNewcomer
(
local_cindex
,
local_iindex
,
key
)
do
# Get the entry waiting to be verified
[{
key
,
entry
}]
=
:ets
.
lookup
(
local_cindex
,
key
)
:ets
.
match
(
local_iindex
,{
:"$1"
,%{
member:
true
,
pub:
entry
.
receiver
}})
|>
Enum
.
count
()
|>
(
fn
x
->
Map
.
merge
(
entry
,%{
toNewcomer:
(
x
!=
0
)
})
end
)
.
()
|>
(
&
:ets
.
insert
(
local_cindex
,{
key
,
&1
}))
.
()
end
end
end
This diff is collapsed.
Click to expand it.
test/certification/augmentation/to_newcomer_test.exs
0 → 100644
+
44
−
0
View file @
3aa5dbee
defmodule
ToNewcomerTest
do
use
ExUnit
.
Case
doctest
Index
.
Augmentation
.
CIndex
setup_all
do
local_cindex
=
:ets
.
new
(
:"test/local_cindex"
,
[
:set
,
:protected
])
local_good_iindex
=
:ets
.
new
(
:"test/local_good_iindex"
,
[
:set
,
:protected
])
local_bad_iindex
=
:ets
.
new
(
:"test/local_bad_iindex"
,
[
:set
,
:protected
])
:ets
.
insert
(
local_cindex
,
{
0
,
%{
receiver:
"XYZ_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
0
,
%{
member:
true
,
pub:
"XYZ_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
1
,
%{
member:
true
,
pub:
"XYZ_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
2
,
%{
member:
true
,
pub:
"XYZ_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
3
,
%{
member:
false
,
pub:
"XYZ_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
4
,
%{
member:
true
,
pub:
"ABC_pkey"
}})
:ets
.
insert
(
local_good_iindex
,
{
5
,
%{
member:
false
,
pub:
"ABC_pkey"
}})
Index
.
Augmentation
.
CIndex
.
toNewcomer
(
local_cindex
,
local_good_iindex
,
0
)
[{
0
,
entry
}]
=
:ets
.
lookup
(
local_cindex
,
0
)
toNewcomer_good
=
entry
.
toNewcomer
:ets
.
insert
(
local_cindex
,
{
0
,
%{
receiver:
"XYZ_pkey"
}})
:ets
.
insert
(
local_bad_iindex
,
{
3
,
%{
member:
false
,
pub:
"XYZ_pkey"
}})
:ets
.
insert
(
local_bad_iindex
,
{
4
,
%{
member:
true
,
pub:
"ABC_pkey"
}})
:ets
.
insert
(
local_bad_iindex
,
{
5
,
%{
member:
false
,
pub:
"ABC_pkey"
}})
Index
.
Augmentation
.
CIndex
.
toNewcomer
(
local_cindex
,
local_bad_iindex
,
0
)
[{
0
,
entry
}]
=
:ets
.
lookup
(
local_cindex
,
0
)
toNewcomer_bad
=
entry
.
toNewcomer
:dets
.
close
(
local_cindex
)
:dets
.
close
(
local_good_iindex
)
:dets
.
close
(
local_bad_iindex
)
:file
.
delete
(
"test/local_cindex"
)
:file
.
delete
(
"test/local_good_iindex"
)
:file
.
delete
(
"test/local_bad_iindex"
)
{
:ok
,
toNewcomer_good:
toNewcomer_good
,
toNewcomer_bad:
toNewcomer_bad
}
end
test
"check toNewcomer"
,
state
do
assert
state
.
toNewcomer_good
==
true
assert
state
.
toNewcomer_bad
==
false
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment