<commit_before>'use strict';

var Database              = require('dbjs')
  , defineBusinessProcess = require('../../model/business-process/base')
  , defineDate            = require('dbjs-ext/date-time/date');

module.exports = function (t, a) {
	var db = new Database()
	  , FormSection = t(db)
	  , TestFormSection
	  , BusinessProcess = defineBusinessProcess(db)
	  , DateType = defineDate(db)
	  , businessProcess, section;

	TestFormSection = FormSection.extend('TestFormSection', {
		actionUrl: { value: 'action' },
		propertyNames: { value: ['prop1', 'prop2', 'prop3'] },
		resolventProperty: { value: 'prop0' },
		resolventValue: { value: true }
	});
	//section's resolvent
	BusinessProcess.prototype.defineProperties(
		{
			prop0: {
				type: db.Boolean,
				required: true,
				value: false
			},
			prop1: { type: db.String, required: true },
			prop2: { type: db.Number },
			prop3: { type: db.Boolean, required: true },
			section: { type: TestFormSection, nested: true }
		}
	);
	businessProcess = new BusinessProcess();
	section = businessProcess.section;
	a(section.actionUrl, 'action');
	a(section.weight, 0); // default value is setup on prototype, so ignore (weight 0)
	businessProcess.prop0 = true;
	a(section.weight, 2);
	a(section.status, 0);
	businessProcess.prop1 = "test";
	a(section.status, 0.5);
	businessProcess.prop0 = false;
	a(section.status, 1);
	businessProcess.prop0 = true;
	businessProcess.prop3 = true;
	a(section.status, 1);
	a(String(section.lastEditDate), String(new DateType(businessProcess.$prop3.lastModified / 1000)));
};<commit_msg>#635 added test coverage for is<propName>Applicable and is<propName>FormApplicable<commit_after>'use strict';

var Database              = require('dbjs')
  , defineBusinessProcess = require('../../model/business-process/base')
  , defineDate            = require('dbjs-ext/date-time/date');

module.exports = function (t, a) {
	var db = new Database()
	  , FormSection = t(db)
	  , TestFormSection
	  , BusinessProcess = defineBusinessProcess(db)
	  , DateType = defineDate(db)
	  , businessProcess, section, Partner;

	TestFormSection = FormSection.extend('TestFormSection', {
		actionUrl: { value: 'action' },
		propertyNames: { value: ['prop1', 'prop2', 'prop3', 'partner/name',
			'partner/hasSameLastName', 'partner/lastName'] },
		resolventProperty: { value: 'prop0' },
		resolventValue: { value: true }
	});
	Partner = db.Object.extend('Partner', {
		name: { type: db.String, required: true },
		hasSameLastName: { type: db.Boolean, required: true },
		lastName: { type: db.String, required: true },
		isLastNameApplicable: { type: db.Boolean, value: function () {
			return this.hasSameLastName === false;
		} }
	});
	['isNameFormApplicable', 'isLastNameFormApplicable',
		'isHasSameLastNameFormApplicable'].forEach(function (name) {
		Partner.prototype.define(name, { type: db.Boolean, value: function (_observe) {
			return _observe(this.master._hasPartner);
		} });
	});
	//section's resolvent
	BusinessProcess.prototype.defineProperties(
		{
			hasPartner: { type: db.Boolean, value: false },
			prop0: {
				type: db.Boolean,
				required: true,
				value: false
			},
			prop1: { type: db.String, required: true },
			prop2: { type: db.Number },
			prop3: { type: db.Boolean, required: true },
			partner: { type: Partner, nested: true },
			section: { type: TestFormSection, nested: true }
		}
	);
	businessProcess = new BusinessProcess();
	section = businessProcess.section;
	a(section.actionUrl, 'action');
	a(section.weight, 0); // default value is setup on prototype, so ignore (weight 0)
	businessProcess.prop0 = true;
	a(section.weight, 2);
	a(section.status, 0);
	businessProcess.prop1 = "test";
	a(section.status, 0.5);
	businessProcess.prop0 = false;
	a(section.status, 1);
	businessProcess.prop0 = true;
	businessProcess.prop3 = true;
	a(section.status, 1);
	a(String(section.lastEditDate), String(new DateType(businessProcess.$prop3.lastModified / 1000)));
	businessProcess.hasPartner = true;
	a(section.weight, 4);
	a(section.status, 0.5);
	businessProcess.partner.name = 'test';
	a(section.weight, 4);
	a(section.status, 0.75);
	businessProcess.partner.hasSameLastName = true;
	a(section.weight, 4);
	a(section.status, 1);
	businessProcess.partner.hasSameLastName = false;
	a(section.status, 0.8);
	businessProcess.partner.lastName = 'test';
	a(section.status, 1);
};
{'fraction_non_alphanumeric': 0.15154285714285715, 'fraction_numerical': 0.015314285714285714, 'mean_word_length': 4.285024154589372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2198388', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1441, 'n_words': 310}