<commit_before>'use strict'


{ ev, EMPTY, processLiterals, processVars } = jinter


describe 'ev', ->
	jinterEv = (string) ->
		tree = esprima.parse string
		processLiterals tree
		processVars tree

		result = ev tree, EMPTY

		if result?
			result.toString()
		else
			'undefined'


	jsEv = (string) ->
		(eval string).toString()


	[
		'1'
		'2 + 3'
		'"asd" + "dsa"'
		'123 + "asd"'
		'"asd" + 123'
		'(function () { return 123; })()'
		'(function (a) { return a; })(123)'
		'(function (a, b) { return a + b; })(123, 456)'
		'({ a: 123 }).a'
		'({ a: 123, b: function () { return this.a } }).b()'
		'var a; a = 123; a'
		'var a, b; a = 123; b = 456; a + b'
		'var a, b; a = b = 123; a + b'
	].forEach (string) ->
		it string, ->
			(expect jinterEv string).toEqual (jsEv string)<commit_msg>Assignments to object members work<commit_after>'use strict'


{ ev, EMPTY, processLiterals, processVars } = jinter


describe 'ev', ->
	jinterEv = (string) ->
		tree = esprima.parse string
		processLiterals tree
		processVars tree

		result = ev tree, EMPTY

		if result?
			result.toString()
		else
			'undefined'


	jsEv = (string) ->
		(eval string).toString()


	[
		'1'
		'2 + 3'
		'"asd" + "dsa"'
		'123 + "asd"'
		'"asd" + 123'
		'(function () { return 123; })()'
		'(function (a) { return a; })(123)'
		'(function (a, b) { return a + b; })(123, 456)'
		'({ a: 123 }).a'
		'({ a: 123, b: function () { return this.a } }).b()'
		'var a; a = 123; a'
		'var a, b; a = 123; b = 456; a + b'
		'var a, b; a = b = 123; a + b'
		'var a; a = {}; a.b = 123; a.b'
	].forEach (string) ->
		it string, ->
			(expect jinterEv string).toEqual (jsEv string)
{'fraction_non_alphanumeric': 0.20267802799756543, 'fraction_numerical': 0.049300060864272674, 'mean_word_length': 2.770642201834862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1533382', 'n_tokens_mistral': 811, 'n_tokens_neox': 663, 'n_words': 203}