<commit_before>-- Copyright (c) 2009-2012 Incremental IP Limited
-- see LICENSE for license information

local sets = require("rima.sets")
local ref = require("rima.sets.ref")

local lib = require("rima.lib")
local core = require("rima.core")
local scope = require("rima.scope")
local number_t = require("rima.types.number_t")
local interface = require("rima.interface")


------------------------------------------------------------------------------

return function(T)
  local E = core.eval
  local R = interface.R
  local sum = interface.sum

  do
    local i, j, I, X, Y = R"i, j, I, X, Y"
    local S = { X={10}, Y={a=20}, I={"a"} }
    T:check_equal(sum{i=interface.pairs(I)}(X[i]), "sum{i in pairs(I)}(X[i])")
    T:check_equal(E(sum{i=interface.pairs(I)}(X[i]), S), 10)

    T:check_equal(sum{["i,j"]=interface.pairs(I)}(Y[j]), "sum{i, j in pairs(I)}(Y[j])")
    T:check_equal(E(sum{["i,j"]=interface.pairs(I)}(Y[j]), S), 20)

    T:check_equal(sum{["i,j"]=interface.pairs(I)}((i+1)*X[i]*Y[j]), "sum{i, j in pairs(I)}((1 + i)*X[i]*Y[j])")
    T:check_equal(E(sum{["i,j"]=interface.pairs(I)}((i+1)*X[i]*Y[j]), S), 400)
  end

  do
    local x, y, Q, r = R"x, y, Q, r"
    local S = { x = {10}, Q = {"a"}, y={{z=13}} }<commit_msg>tidied sets tests<commit_after>-- Copyright (c) 2009-2012 Incremental IP Limited
-- see LICENSE for license information

local sets = require("rima.sets")
local ref = require("rima.sets.ref")

local lib = require("rima.lib")
local scope = require("rima.scope")
local number_t = require("rima.types.number_t")
local interface = require("rima.interface")


------------------------------------------------------------------------------

return function(T)
  local E = interface.eval
  local R = interface.R
  local sum = interface.sum

  do
    local i, j, I, X, Y = R"i, j, I, X, Y"
    local S = { X={10}, Y={a=20}, I={"a"} }
    T:check_equal(sum{i=interface.pairs(I)}(X[i]), "sum{i in pairs(I)}(X[i])")
    T:check_equal(E(sum{i=interface.pairs(I)}(X[i]), S), 10)

    T:check_equal(sum{["i,j"]=interface.pairs(I)}(Y[j]), "sum{i, j in pairs(I)}(Y[j])")
    T:check_equal(E(sum{["i,j"]=interface.pairs(I)}(Y[j]), S), 20)

    T:check_equal(sum{["i,j"]=interface.pairs(I)}((i+1)*X[i]*Y[j]), "sum{i, j in pairs(I)}((1 + i)*X[i]*Y[j])")
    T:check_equal(E(sum{["i,j"]=interface.pairs(I)}((i+1)*X[i]*Y[j]), S), 400)
  end

  do
    local x, y, Q, r = R"x, y, Q, r"
    local S = { x = {10}, Q = {"a"}, y={{z=13}} }
{'fraction_non_alphanumeric': 0.2931808901592487, 'fraction_numerical': 0.021233156390363415, 'mean_word_length': 3.2832167832167833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '1169460', 'n_tokens_mistral': 1027, 'n_tokens_neox': 980, 'n_words': 205}