<commit_before>%%
%%  Copyright 2014, <NAME> <<EMAIL>>
%%
%%   Licensed under the Apache License, Version 2.0 (the "License");
%%   you may not use this file except in compliance with the License.
%%   You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%%   Unless required by applicable law or agreed to in writing, software
%%   distributed under the License is distributed on an "AS IS" BASIS,
%%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%   See the License for the specific language governing permissions and
%%   limitations under the License.
%%

-module(ecapnp_props).

-include_lib("proper/include/proper.hrl").
-include_lib("ecapnp/include/ecapnp.hrl").

-define(TRACE(E),
        fun (__V) ->
                io:format("TRACE: ~s:~b ~s = ~p~n", [?FILE, ?LINE, ??E, __V]),
                __V
        end(E)).

-define(T(E), ?TRACE(E)).


%%% ----------------------------------------
%% property types
%%% ----------------------------------------

%% generate any kind of primitive value that capnp can represent.
data_value() ->
    union(
      [?LET(B, boolean(), {1, bool, B}),
       ?LET(I, integer(-16#80, 16#7f), {8, int8, I}),
       ?LET(I, integer(-16#8000, 16#7fff), {16, int16, I}),
       ?LET(I, integer(-16#80000000, 16#7fffffff), {32, int32, I}),
       ?LET(I, integer(-16#8000000000000000, 16#7fffffffffffffff), {64, int64, I}),
       ?LET(I, integer(0, 16#ff), {8, uint8, I}),
       ?LET(I, integer(0, 16#ffff), {16, uint16, I}),
       ?LET(I, integer(0, 16#ffffffff), {32, uint32, I}),
       ?LET(I, integer(0, 16#ffffffffffffffff), {64, uint64, I}),
       ?LET(F, float(-3.4e38, 3.4e38), {32, float32, F}), %% bound it to just under 32 bit
       ?LET(F, float(), {64, float64, F}), %% erlang floats are 64 bit
       ?LET([{S, T}, V], %% test infinity and NaN values..
            [union([{32, float32}, {64, float64}]),
             union([nan, inf, '-inf'])],
            {S, T, V})
      ]).

ptr_value() ->
    union(
      [?LET({T, V}, list_ptr(), {{list, T}, V, <<0,0,0,0,0,0,0,0>>}),
       ?LET(V, binary(), {text, V, <<>>})
      ]).

list_ptr() ->
    union(
      [{bool, list(boolean())},
       {int8, list(integer(-16#80, 16#7f))},
       {int16, list(integer(-16#8000, 16#7fff))},
       {int32, list(integer(-16#80000000, 16#7fffffff))},
       {int64, list(integer(-16#8000000000000000, 16#7fffffffffffffff))},
       {uint8, list(integer(0, 16#ff))},
       {uint16, list(integer(0, 16#ffff))},
       {uint32, list(integer(0, 16#ffffffff))},
       {uint64, list(integer(0, 16#ffffffffffffffff))}
       %% avoid floats, as they don't compare well..
       %%{float32, list(float(-3.4e38, 3.4e38))},
       %%{float64, list(float())}
      ]).

%% struct ref with at least one word of data
struct_ref_data() -> struct_ref(pos_integer(), non_neg_integer()).
%% struct ref with at least one pointer
struct_ref_ptr() -> struct_ref(non_neg_integer(), pos_integer()).

%% any struct ref, even null
struct_ref() -> struct_ref(range(0, inf), range(0, inf)).
<commit_msg>test list of texts.<commit_after>%%
%%  Copyright 2014, <NAME> <<EMAIL>>
%%
%%   Licensed under the Apache License, Version 2.0 (the "License");
%%   you may not use this file except in compliance with the License.
%%   You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%%   Unless required by applicable law or agreed to in writing, software
%%   distributed under the License is distributed on an "AS IS" BASIS,
%%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%   See the License for the specific language governing permissions and
%%   limitations under the License.
%%

-module(ecapnp_props).

-include_lib("proper/include/proper.hrl").
-include_lib("ecapnp/include/ecapnp.hrl").

-define(TRACE(E),
        fun (__V) ->
                io:format("TRACE: ~s:~b ~s = ~p~n", [?FILE, ?LINE, ??E, __V]),
                __V
        end(E)).

-define(T(E), ?TRACE(E)).


%%% ----------------------------------------
%% property types
%%% ----------------------------------------

%% generate any kind of primitive value that capnp can represent.
data_value() ->
    union(
      [?LET(B, boolean(), {1, bool, B}),
       ?LET(I, integer(-16#80, 16#7f), {8, int8, I}),
       ?LET(I, integer(-16#8000, 16#7fff), {16, int16, I}),
       ?LET(I, integer(-16#80000000, 16#7fffffff), {32, int32, I}),
       ?LET(I, integer(-16#8000000000000000, 16#7fffffffffffffff), {64, int64, I}),
       ?LET(I, integer(0, 16#ff), {8, uint8, I}),
       ?LET(I, integer(0, 16#ffff), {16, uint16, I}),
       ?LET(I, integer(0, 16#ffffffff), {32, uint32, I}),
       ?LET(I, integer(0, 16#ffffffffffffffff), {64, uint64, I}),
       ?LET(F, float(-3.4e38, 3.4e38), {32, float32, F}), %% bound it to just under 32 bit
       ?LET(F, float(), {64, float64, F}), %% erlang floats are 64 bit
       ?LET([{S, T}, V], %% test infinity and NaN values..
            [union([{32, float32}, {64, float64}]),
             union([nan, inf, '-inf'])],
            {S, T, V})
      ]).

ptr_value() ->
    union(
      [?LET({T, V}, list_ptr(), {{list, T}, V, <<0,0,0,0,0,0,0,0>>}),
       ?LET(V, binary(), {text, V, <<>>})
      ]).

list_ptr() ->
    union(
      [{bool, list(boolean())},
       {int8, list(integer(-16#80, 16#7f))},
       {int16, list(integer(-16#8000, 16#7fff))},
       {int32, list(integer(-16#80000000, 16#7fffffff))},
       {int64, list(integer(-16#8000000000000000, 16#7fffffffffffffff))},
       {uint8, list(integer(0, 16#ff))},
       {uint16, list(integer(0, 16#ffff))},
       {uint32, list(integer(0, 16#ffffffff))},
       {uint64, list(integer(0, 16#ffffffffffffffff))},
       %% avoid floats, as they don't compare well..
       %%{float32, list(float(-3.4e38, 3.4e38))},
       %%{float64, list(float())},
       {text, list(binary())}
      ]).

%% struct ref with at least one word of data
struct_ref_data() -> struct_ref(pos_integer(), non_neg_integer()).
%% struct ref with at least one pointer
struct_ref_ptr() -> struct_ref(non_neg_integer(), pos_integer()).

%% any struct ref, even null
struct_ref() -> struct_ref(range(0, inf), range(0, inf)).

{'fraction_non_alphanumeric': 0.2164155177941648, 'fraction_numerical': 0.07213850593138826, 'mean_word_length': 2.865551425030979, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 24, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5964902', 'n_tokens_mistral': 2442, 'n_tokens_neox': 2135, 'n_words': 593}