blob: 140d0205102c3752eb2c93f1132b36ce21524a9f [file] [log] [blame] [edit]
{{header}}
{{object 1 0}} <<
/Type /Catalog
/Pages 2 0 R
/AcroForm <<
/Fields [
4 0 R
10 0 R
11 0 R
12 0 R
]
/DR 5 0 R
>>
>>
endobj
{{object 2 0}} <<
/Count 1
/Kids [ 3 0 R ]
/Type /Pages
>>
endobj
{{object 3 0}} <<
/Type /Page
/Parent 2 0 R
/Resources 5 0 R
/MediaBox [ 0 0 300 200 ]
/Contents 8 0 R
/Annots [
4 0 R
10 0 R
11 0 R
12 0 R
]
>>
endobj
{{object 4 0}} <<
/Type /Annot
/FT /Tx
/T (Text Box)
/DA (0 0 0 rg /F1 12 Tf)
/Rect [ 100 160 200 190 ]
/Subtype /Widget
/AA <<
/C 16 0 R
/F 17 0 R
/K 18 0 R
/V 19 0 R
>>
>>
endobj
{{object 5 0}} <<
/Font 6 0 R
>>
endobj
{{object 6 0}} <<
/F1 7 0 R
>>
endobj
{{object 7 0}} <<
/Type /Font
/Subtype /Type1
/BaseFont /Helvetica
>>
endobj
{{object 8 0}} <<
{{streamlen}}
>>
stream
endstream
endobj
{{object 10 0}} <<
/Type /Annot
/Subtype /Widget
/FT /Tx
/T (Text2)
/DA (0 0 0 rg /F1 12 Tf)
/Rect [100 0 200 30]
/V (123)
>>
endobj
{{object 11 0}} <<
/Type /Annot
/Subtype /Widget
/FT /Tx
/T (Text3)
/DA (0 0 0 rg /F1 12 Tf)
/Rect [100 40 200 70]
/V (456)
>>
endobj
{{object 12 0}} <<
/Type /Annot
/Subtype /Widget
/FT /Tx
/T (Text4)
/DA (0 0 0 rg /F1 12 Tf)
/Rect [100 80 200 110]
/V (407.96)
>>
endobj
{{object 16 0}} <<
/S /JavaScript
/JS (
app.alert('Unexpected script 16');
)
>>
endobj
{{object 17 0}} <<
/S /JavaScript
/JS (
function expect(initial, expression, expected) {
try {
event.value = initial;
var actual = eval(expression);
if (actual == expected) {
app.alert('PASS: ' + expression + ' = ' + actual);
} else {
app.alert('FAIL: ' + expression + ' = ' + actual + ', expected ' + expected + " ");
}
} catch (e) {
app.alert('ERROR: ' + e);
}
}
function expectEventValue(initial, expression, expected) {
try {
event.value = initial;
eval(expression);
var actual = event.value;
if (actual == expected) {
app.alert('PASS: ' + expression + ' = ' + actual);
} else {
app.alert('FAIL: ' + expression + ' = ' + actual + ', expected ' + expected + " ");
}
} catch (e) {
app.alert('ERROR: ' + e);
}
}
function expectError(initial, expression) {
try {
event.value = initial;
var actual = eval(expression);
app.alert('FAIL: ' + expression + ' = ' + actual + ', expected to throw');
} catch (e) {
app.alert('PASS: ' + expression + ' threw ' + e);
}
}
try {
app.alert("*** starting test 1 ***");
expectError('', "AFDate_Format()");
expectError('', "AFDate_Format(1, 2)");
expectEventValue("GMT", "AFDate_Format(1)", "1/1/70");
expectEventValue("PDT", "AFDate_Format(1)", "5/9/14");
expectEventValue("GMT", "AFDate_Format('blooey')", "1/1");
expectEventValue("PDT", "AFDate_Format('blooey')", "5/9");
app.alert("**********************");
expectError('', "AFDate_FormatEx()");
expectError('', "AFDate_FormatEx(1, 2)");
expectEventValue("x", "AFDate_FormatEx(2)", "2");
expectEventValue("x", "AFDate_FormatEx('blooey')", "blooey");
expectEventValue("x", "AFDate_FormatEx('m/d')", "5/9");
// TODO(crbug.com/572901): This is wrong. AFDate_FormatEx() should throw
// an error like Adobe Acrobat.
expectEventValue("12302015", "AFDate_FormatEx('mm/dd/yyyy')", "12/02/2015");
expectEventValue("20122015", "AFDate_FormatEx('mm/dd/yyyy')", "05/09/2014");
app.alert("**********************");
expectError('', "AFDate_Keystroke()");
expectError('', "AFDate_Keystroke(1, 2)");
expectEventValue("04/19", "AFDate_Keystroke(2)", "04/19");
expectEventValue("04/19/15", "AFDate_Keystroke('blooey')", "04/19/15");
app.alert("**********************");
expectError('', "AFDate_KeystrokeEx()");
expectError('', "AFDate_KeystrokeEx(1, 2)");
expectEventValue("x", "AFDate_KeystrokeEx(2)", "x");
expectEventValue("x", "AFDate_KeystrokeEx('blooey')", "x");
expectEventValue("x", "AFDate_KeystrokeEx('m/d')", "x");
app.alert("**********************");
expectError('', "AFExtractNums()");
expectError('', "AFExtractNums(1, 2)");
expect('', "AFExtractNums('100 200')", "100,200");
app.alert("**********************");
expectError('', "AFMakeNumber()");
expectError('', "AFMakeNumber(1, 2)");
expect('', "AFMakeNumber('2blooey')", 0);
expect('', "AFMakeNumber(1)", 1);
expect('', "AFMakeNumber('1.2')", 1.2);
expect('', "AFMakeNumber('1,2')", 1.2);
app.alert("**********************");
expectError('', "AFMergeChange()");
expectError('', "AFMergeChange(1, 2)");
expect("one", "AFMergeChange(undefined)", "one");
app.alert("**********************");
expectError('', "AFNumber_Format()");
expectError('', "AFNumber_Format(0, 1, 0, 0, '', false, 42)");
expectEventValue("blooey", "AFNumber_Format(0, 1, 0, 0, '', false)", 0);
expectEventValue(12, "AFNumber_Format(0, 1, 0, 0, '', false)", 12);
app.alert("**********************");
expectError('', "AFNumber_Keystroke()");
expectError('', "AFNumber_Keystroke(1)");
expectError("abc", "AFNumber_Keystroke(1, 2)");
expectEventValue("123", "AFNumber_Keystroke(1, 2)", "123");
expectEventValue("123", "AFNumber_Keystroke(1, 2, 3)", "123");
app.alert("**********************");
expectError('', "AFParseDateEx()");
expectError('', "AFParseDateEx(1, 2, 3)");
expect('', "AFParseDateEx(1, 2)", "1399672130000");
app.alert("**********************");
// Requires at least 2 arguments.
expectError('', "AFPercent_Format()");
expectError('', "AFPercent_Format(0)");
// Extra arguments are ignored.
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0, 0)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0, 0, 0)", "-512.3%");
// There seems to be an extra bPercentPrepend parameter that may have been
// added in later versions.
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 1)", "%-512.3");
expectEventValue(-5.1234, "AFPercent_Format(1, 0, 2)", "%-512.3");
expectEventValue('', "AFPercent_Format(10, 0, 0)", "0.0000000000%");
expectEventValue('', "AFPercent_Format(10, 0, 1)", "%0.0000000000");
expectEventValue('', "AFPercent_Format(10, 0, 2)", "%0.0000000000");
expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 0)", "98,765,432,100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 0)", "98765432100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 0)", "98.765.432.100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 1)", "%98,765,432,100");
expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 1)", "%98765432100");
expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 1)", "%98.765.432.100");
expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 2)", "%98,765,432,100");
expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 2)", "%98765432100");
expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 2)", "%98.765.432.100");
// InvalidArgsError
expectError(0, "AFPercent_Format(-3, 0)");
expectError(0, "AFPercent_Format(-3, 1)");
expectError(0, "AFPercent_Format(-1, 3)");
expectError(0, "AFPercent_Format(0, -3)");
expectError(0, "AFPercent_Format(0, -1)");
expectError(0, "AFPercent_Format(0, 50)");
expectError(0, "AFPercent_Format(0, 51)");
expectEventValue('', "AFPercent_Format(0, 0)", "0%");
expectEventValue('', "AFPercent_Format(0, 1)", "0%");
expectEventValue('', "AFPercent_Format(0, 2)", "0%");
expectEventValue('', "AFPercent_Format(0, 3)", "0%");
expectEventValue('', "AFPercent_Format(0, 4)", "0%");
expectEventValue('', "AFPercent_Format(1, 0)", "0.0%");
expectEventValue('', "AFPercent_Format(1, 1)", "0.0%");
expectEventValue('', "AFPercent_Format(1, 2)", "0,0%");
expectEventValue('', "AFPercent_Format(1, 3)", "0,0%");
expectEventValue('', "AFPercent_Format(1, 4)", "0.0%");
expectEventValue('', "AFPercent_Format(2, 0)", "0.00%");
expectEventValue('', "AFPercent_Format(2, 1)", "0.00%");
expectEventValue('', "AFPercent_Format(2, 2)", "0,00%");
expectEventValue('', "AFPercent_Format(2, 3)", "0,00%");
expectEventValue('', "AFPercent_Format(2, 4)", "0.00%");
expectEventValue('', "AFPercent_Format(3, 0)", "0.000%");
expectEventValue('', "AFPercent_Format(3, 1)", "0.000%");
expectEventValue('', "AFPercent_Format(3, 2)", "0,000%");
expectEventValue('', "AFPercent_Format(3, 3)", "0,000%");
expectEventValue('', "AFPercent_Format(3, 4)", "0.000%");
expectEventValue('', "AFPercent_Format(10, 0)", "0.0000000000%");
expectEventValue('', "AFPercent_Format(10, 1)", "0.0000000000%");
expectEventValue('', "AFPercent_Format(10, 2)", "0,0000000000%");
expectEventValue('', "AFPercent_Format(10, 3)", "0,0000000000%");
expectEventValue('', "AFPercent_Format(10, 4)", "0.0000000000%");
expectEventValue(0, "AFPercent_Format(0, 0)", "0%");
expectEventValue(0, "AFPercent_Format(0, 1)", "0%");
expectEventValue(0, "AFPercent_Format(0, 2)", "0%");
expectEventValue(0, "AFPercent_Format(0, 3)", "0%");
expectEventValue(0, "AFPercent_Format(0, 4)", "0%");
expectEventValue(0, "AFPercent_Format(1, 0)", "0.0%");
expectEventValue(0, "AFPercent_Format(1, 1)", "0.0%");
expectEventValue(0, "AFPercent_Format(1, 2)", "0,0%");
expectEventValue(0, "AFPercent_Format(1, 3)", "0,0%");
expectEventValue(0, "AFPercent_Format(1, 4)", "0.0%");
expectEventValue(0, "AFPercent_Format(2, 0)", "0.00%");
expectEventValue(0, "AFPercent_Format(2, 1)", "0.00%");
expectEventValue(0, "AFPercent_Format(2, 2)", "0,00%");
expectEventValue(0, "AFPercent_Format(2, 3)", "0,00%");
expectEventValue(0, "AFPercent_Format(2, 4)", "0.00%");
expectEventValue(0, "AFPercent_Format(3, 0)", "0.000%");
expectEventValue(0, "AFPercent_Format(3, 1)", "0.000%");
expectEventValue(0, "AFPercent_Format(3, 2)", "0,000%");
expectEventValue(0, "AFPercent_Format(3, 3)", "0,000%");
expectEventValue(0, "AFPercent_Format(3, 4)", "0.000%");
expectEventValue(0, "AFPercent_Format(10, 0)", "0.0000000000%");
expectEventValue(0, "AFPercent_Format(10, 1)", "0.0000000000%");
expectEventValue(0, "AFPercent_Format(10, 2)", "0,0000000000%");
expectEventValue(0, "AFPercent_Format(10, 3)", "0,0000000000%");
expectEventValue(0, "AFPercent_Format(10, 4)", "0.0000000000%");
expectEventValue(-5.1234, "AFPercent_Format(0, 0)", "-512%");
expectEventValue(-5.1234, "AFPercent_Format(0, 1)", "-512%");
expectEventValue(-5.1234, "AFPercent_Format(0, 2)", "-512%");
expectEventValue(-5.1234, "AFPercent_Format(0, 3)", "-512%");
expectEventValue(-5.1234, "AFPercent_Format(0, 4)", "-512%");
expectEventValue(-5.1234, "AFPercent_Format(1, 0)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 1)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 2)", "-512,3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 3)", "-512,3%");
expectEventValue(-5.1234, "AFPercent_Format(1, 4)", "-512.3%");
expectEventValue(-5.1234, "AFPercent_Format(2, 0)", "-512.34%");
expectEventValue(-5.1234, "AFPercent_Format(2, 1)", "-512.34%");
expectEventValue(-5.1234, "AFPercent_Format(2, 2)", "-512,34%");
expectEventValue(-5.1234, "AFPercent_Format(2, 3)", "-512,34%");
expectEventValue(-5.1234, "AFPercent_Format(2, 4)", "-512.34%");
expectEventValue(-5.1234, "AFPercent_Format(3, 0)", "-512.340%");
expectEventValue(-5.1234, "AFPercent_Format(3, 1)", "-512.340%");
expectEventValue(-5.1234, "AFPercent_Format(3, 2)", "-512,340%");
expectEventValue(-5.1234, "AFPercent_Format(3, 3)", "-512,340%");
expectEventValue(-5.1234, "AFPercent_Format(3, 4)", "-512.340%");
expectEventValue(-5.1234, "AFPercent_Format(10, 0)", "-512.3400000000%");
expectEventValue(-5.1234, "AFPercent_Format(10, 1)", "-512.3400000000%");
expectEventValue(-5.1234, "AFPercent_Format(10, 2)", "-512,3400000000%");
expectEventValue(-5.1234, "AFPercent_Format(10, 3)", "-512,3400000000%");
expectEventValue(-5.1234, "AFPercent_Format(10, 4)", "-512.3400000000%");
expectEventValue(5.1234, "AFPercent_Format(0, 0)", "512%");
expectEventValue(5.1234, "AFPercent_Format(0, 1)", "512%");
expectEventValue(5.1234, "AFPercent_Format(0, 2)", "512%");
expectEventValue(5.1234, "AFPercent_Format(0, 3)", "512%");
expectEventValue(5.1234, "AFPercent_Format(0, 4)", "512%");
expectEventValue(5.1234, "AFPercent_Format(1, 0)", "512.3%");
expectEventValue(5.1234, "AFPercent_Format(1, 1)", "512.3%");
expectEventValue(5.1234, "AFPercent_Format(1, 2)", "512,3%");
expectEventValue(5.1234, "AFPercent_Format(1, 3)", "512,3%");
expectEventValue(5.1234, "AFPercent_Format(1, 4)", "512.3%");
expectEventValue(5.1234, "AFPercent_Format(2, 0)", "512.34%");
expectEventValue(5.1234, "AFPercent_Format(2, 1)", "512.34%");
expectEventValue(5.1234, "AFPercent_Format(2, 2)", "512,34%");
expectEventValue(5.1234, "AFPercent_Format(2, 3)", "512,34%");
expectEventValue(5.1234, "AFPercent_Format(2, 4)", "512.34%");
expectEventValue(5.1234, "AFPercent_Format(3, 0)", "512.340%");
expectEventValue(5.1234, "AFPercent_Format(3, 1)", "512.340%");
expectEventValue(5.1234, "AFPercent_Format(3, 2)", "512,340%");
expectEventValue(5.1234, "AFPercent_Format(3, 3)", "512,340%");
expectEventValue(5.1234, "AFPercent_Format(3, 4)", "512.340%");
expectEventValue(5.1234, "AFPercent_Format(10, 0)", "512.3400000000%");
expectEventValue(5.1234, "AFPercent_Format(10, 1)", "512.3400000000%");
expectEventValue(5.1234, "AFPercent_Format(10, 2)", "512,3400000000%");
expectEventValue(5.1234, "AFPercent_Format(10, 3)", "512,3400000000%");
expectEventValue(5.1234, "AFPercent_Format(10, 4)", "512.3400000000%");
expectEventValue(12.3456, "AFPercent_Format(1, 0)", "1,234.6%");
expectEventValue(12.3456, "AFPercent_Format(4, 1)", "1234.5600%");
expectEventValue(0.009876, "AFPercent_Format(0, 0)", "1%");
expectEventValue(0.009876, "AFPercent_Format(0, 1)", "1%");
expectEventValue(0.009876, "AFPercent_Format(0, 2)", "1%");
expectEventValue(0.009876, "AFPercent_Format(0, 3)", "1%");
expectEventValue(0.009876, "AFPercent_Format(0, 4)", "1%");
expectEventValue(0.009876, "AFPercent_Format(1, 0)", "1.0%");
expectEventValue(0.009876, "AFPercent_Format(1, 1)", "1.0%");
expectEventValue(0.009876, "AFPercent_Format(1, 2)", "1,0%");
expectEventValue(0.009876, "AFPercent_Format(1, 3)", "1,0%");
expectEventValue(0.009876, "AFPercent_Format(1, 4)", "1.0%");
expectEventValue(0.009876, "AFPercent_Format(2, 0)", "0.99%");
expectEventValue(0.009876, "AFPercent_Format(2, 1)", "0.99%");
expectEventValue(0.009876, "AFPercent_Format(2, 2)", "0,99%");
expectEventValue(0.009876, "AFPercent_Format(2, 3)", "0,99%");
expectEventValue(0.009876, "AFPercent_Format(2, 4)", "0.99%");
expectEventValue(0.009876, "AFPercent_Format(3, 0)", "0.988%");
expectEventValue(0.009876, "AFPercent_Format(3, 1)", "0.988%");
expectEventValue(0.009876, "AFPercent_Format(3, 2)", "0,988%");
expectEventValue(0.009876, "AFPercent_Format(3, 3)", "0,988%");
expectEventValue(0.009876, "AFPercent_Format(3, 4)", "0.988%");
expectEventValue(0.009876, "AFPercent_Format(10, 0)", "0.9876000000%");
expectEventValue(0.009876, "AFPercent_Format(10, 1)", "0.9876000000%");
expectEventValue(0.009876, "AFPercent_Format(10, 2)", "0,9876000000%");
expectEventValue(0.009876, "AFPercent_Format(10, 3)", "0,9876000000%");
expectEventValue(0.009876, "AFPercent_Format(10, 4)", "0.9876000000%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 0)", "98,765,432,100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 1)", "98765432100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 2)", "98.765.432.100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 3)", "98765432100%");
expectEventValue(987654321.001234, "AFPercent_Format(0, 4)", "98'765'432'100%");
expectEventValue(987654321.001234, "AFPercent_Format(1, 0)", "98,765,432,100.1%");
expectEventValue(987654321.001234, "AFPercent_Format(1, 1)", "98765432100.1%");
expectEventValue(987654321.001234, "AFPercent_Format(1, 2)", "98.765.432.100,1%");
expectEventValue(987654321.001234, "AFPercent_Format(1, 3)", "98765432100,1%");
expectEventValue(987654321.001234, "AFPercent_Format(1, 4)", "98'765'432'100.1%");
expectEventValue(987654321.001234, "AFPercent_Format(2, 0)", "98,765,432,100.12%");
expectEventValue(987654321.001234, "AFPercent_Format(2, 1)", "98765432100.12%");
expectEventValue(987654321.001234, "AFPercent_Format(2, 2)", "98.765.432.100,12%");
expectEventValue(987654321.001234, "AFPercent_Format(2, 3)", "98765432100,12%");
expectEventValue(987654321.001234, "AFPercent_Format(2, 4)", "98'765'432'100.12%");
expectEventValue(987654321.001234, "AFPercent_Format(3, 0)", "98,765,432,100.123%");
expectEventValue(987654321.001234, "AFPercent_Format(3, 1)", "98765432100.123%");
expectEventValue(987654321.001234, "AFPercent_Format(3, 2)", "98.765.432.100,123%");
expectEventValue(987654321.001234, "AFPercent_Format(3, 3)", "98765432100,123%");
expectEventValue(987654321.001234, "AFPercent_Format(3, 4)", "98'765'432'100.123%");
expectEventValue(987654321.001234, "AFPercent_Format(10, 0)", "98,765,432,100.1234130859%");
expectEventValue(987654321.001234, "AFPercent_Format(10, 1)", "98765432100.1234130859%");
expectEventValue(987654321.001234, "AFPercent_Format(10, 2)", "98.765.432.100,1234130859%");
expectEventValue(987654321.001234, "AFPercent_Format(10, 3)", "98765432100,1234130859%");
expectEventValue(987654321.001234, "AFPercent_Format(10, 4)", "98'765'432'100.1234130859%");
expectEventValue(987654321, "AFPercent_Format(0, 0)", "98,765,432,100%");
expectEventValue(987654321, "AFPercent_Format(0, 1)", "98765432100%");
expectEventValue(987654321, "AFPercent_Format(0, 2)", "98.765.432.100%");
expectEventValue(987654321, "AFPercent_Format(0, 3)", "98765432100%");
expectEventValue(987654321, "AFPercent_Format(0, 4)", "98'765'432'100%");
expectEventValue(987654321, "AFPercent_Format(1, 0)", "98,765,432,100.0%");
expectEventValue(987654321, "AFPercent_Format(1, 1)", "98765432100.0%");
expectEventValue(987654321, "AFPercent_Format(1, 2)", "98.765.432.100,0%");
expectEventValue(987654321, "AFPercent_Format(1, 3)", "98765432100,0%");
expectEventValue(987654321, "AFPercent_Format(1, 4)", "98'765'432'100.0%");
expectEventValue(987654321, "AFPercent_Format(2, 0)", "98,765,432,100.00%");
expectEventValue(987654321, "AFPercent_Format(2, 1)", "98765432100.00%");
expectEventValue(987654321, "AFPercent_Format(2, 2)", "98.765.432.100,00%");
expectEventValue(987654321, "AFPercent_Format(2, 3)", "98765432100,00%");
expectEventValue(987654321, "AFPercent_Format(2, 4)", "98'765'432'100.00%");
expectEventValue(987654321, "AFPercent_Format(3, 0)", "98,765,432,100.000%");
expectEventValue(987654321, "AFPercent_Format(3, 1)", "98765432100.000%");
expectEventValue(987654321, "AFPercent_Format(3, 2)", "98.765.432.100,000%");
expectEventValue(987654321, "AFPercent_Format(3, 3)", "98765432100,000%");
expectEventValue(987654321, "AFPercent_Format(3, 4)", "98'765'432'100.000%");
expectEventValue(987654321, "AFPercent_Format(10, 0)", "98,765,432,100.0000000000%");
expectEventValue(987654321, "AFPercent_Format(10, 1)", "98765432100.0000000000%");
expectEventValue(987654321, "AFPercent_Format(10, 2)", "98.765.432.100,0000000000%");
expectEventValue(987654321, "AFPercent_Format(10, 3)", "98765432100,0000000000%");
expectEventValue(987654321, "AFPercent_Format(10, 4)", "98'765'432'100.0000000000%");
expectEventValue(0.01, "AFPercent_Format(1, 0)", "1.0%");
expectEventValue(0.001, "AFPercent_Format(1, 0)", "0.1%");
expectEventValue(0.0001, "AFPercent_Format(1, 0)", "0.0%");
expectEventValue(0.00001, "AFPercent_Format(1, 0)", "0.0%");
expectEventValue(0.000001, "AFPercent_Format(1, 0)", "0.0%");
expectEventValue(0.000001, "AFPercent_Format(10, 2)", "0,0001000000%");
// Acrobat behaves strangely with smaller values.
// expectEventValue(0.0000001, "AFPercent_Format(1, 0)", "-170.0%");
// expectEventValue(0.00000001, "AFPercent_Format(1, 0)", "-180.0%");
expectEventValue(0, "AFPercent_Format(20, 0)", "0.00000000000000000000%");
expectEventValue(0, "AFPercent_Format(308, 0)", "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%");
// Acrobat starts failing here.
// expectEventValue(0, "AFPercent_Format(309, 0)", "-1.#IND000...000%");
expectEventValue(0.000001, "AFPercent_Format(308, 0)", "0.00009999999999999999123964644631712417321978136897087097167968750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%");
// After 512, Acrobat probably ran out of buffer space.
expectEventValue(0, "AFPercent_Format(513, 0)", "%");
app.alert("**********************");
expectError('', "AFPercent_Keystroke()");
expectError('', "AFPercent_Keystroke(1)");
expectError("abc", "AFPercent_Keystroke(1, 0)");
expectEventValue(".123", "AFPercent_Keystroke(1, 0)", ".123");
app.alert("**********************");
expectError('', "AFRange_Validate()", '');
expectError('', "AFRange_Validate(1, 2, 3, 4, 5)", '');
expectEventValue("1", "AFRange_Validate(true, 2, true, 4)", "1"); // Notifies "between".
expectEventValue("5", "AFRange_Validate(true, 2, true, 4)", "5"); // Notifies "between".
expectEventValue("1", "AFRange_Validate(true, 2, false, 4)", "1"); // Notifies "greater".
expectEventValue("5", "AFRange_Validate(false, 2, true, 4)", "5"); // Notifies "less".
expectEventValue("3", "AFRange_Validate(true, 2, true, 4)", "3"); // No notification.
expectEventValue("1", "AFRange_Validate(false, 2, true, 4)", "1"); // No notification.
expectEventValue("5", "AFRange_Validate(true, 2, false, 4)", "5"); // No notification.
app.alert("**********************");
expectError('', "AFSimple()", 2);
expectError('', "AFSimple(1, 2, 3, 4)");
expectError('', "AFSimple(1, 2, 3)");
expectError('', "AFSimple('nonesuch', 2, 3)");
expect('', "AFSimple('AVG', 2, 3)", 2.5);
expect('', "AFSimple('MIN', 2, 3)", 2);
expect('', "AFSimple('MAX', 2, 3)", 3);
expect('', "AFSimple('SUM', 2, 3)", 5);
expect('', "AFSimple('PRD', 2, 3)", 6);
expectError('', "AFSimple('AVG', 2, 'nonesuch')");
expectError('', "AFSimple('MIN', 2, 'nonesuch')");
expectError('', "AFSimple('MAX', 2, 'nonesuch')");
expectError('', "AFSimple('SUM', 2, 'nonesuch')");
expectError('', "AFSimple('PRD', 2, 'nonesuch')");
app.alert("**********************");
// These two should throw "TypeError", not "AFSimple_Calculate".
// https://crbug.com/pdfium/1396
expectError('', "AFSimple_Calculate()");
expectError('', "AFSimple_Calculate(1)");
// This should "pass", but currently throws an error.
// https://crbug.com/pdfium/1396
expectEventValue('', "AFSimple_Calculate('blooey', ['Text2', 'Text3'])", 0);
// This should fail with TypeError, since a field does not exist, but
// currently passes. https://crbug.com/pdfium/1396
expectEventValue('', "AFSimple_Calculate('AVG', [1, 'nonesuch', {'crud': 32}])", 0);
expectEventValue('', "AFSimple_Calculate('AVG', ['Text2', 'Text3'])", (123 + 456) / 2);
expectEventValue('', "AFSimple_Calculate('SUM', ['Text2', 'Text3'])", 123 + 456);
expectEventValue('', "AFSimple_Calculate('PRD', ['Text2', 'Text3'])", 123 * 456);
expectEventValue('', "AFSimple_Calculate('MIN', ['Text2', 'Text3'])", 123);
expectEventValue('', "AFSimple_Calculate('MAX', ['Text2', 'Text3'])", 456);
expectEventValue('', "AFSimple_Calculate('AVG', 'Text2, Text3')", (123 + 456) / 2);
expectEventValue('', "AFSimple_Calculate('AVG', ['Text4'])", 407.96);
expectEventValue('', "AFSimple_Calculate('SUM', ['Text4'])", 407.96);
expectEventValue('', "AFSimple_Calculate('MIN', ['Text4'])", 407.96);
expectEventValue('', "AFSimple_Calculate('MAX', ['Text4'])", 407.96);
expectEventValue('', "AFSimple_Calculate('AVG', ['Text2', 'Text4'])", (123 + 407.96) / 2);
expectEventValue('', "AFSimple_Calculate('SUM', ['Text2', 'Text4'])", 123 + 407.96);
expectEventValue('', "AFSimple_Calculate('PRD', ['Text2', 'Text4'])", 50179.08);
app.alert("**********************");
expectError('', "AFSpecial_Format()", '');
expectError('', "AFSpecial_Format(1, 2)", '');
expectEventValue('', "AFSpecial_Format(0)", "");
expectEventValue('', "AFSpecial_Format(1)", "-");
expectEventValue('', "AFSpecial_Format(2)", "-");
expectEventValue('', "AFSpecial_Format(3)", "--");
expectEventValue("0123456789", "AFSpecial_Format(0)", "01234");
expectEventValue("0123456789", "AFSpecial_Format(1)", "01234-5678");
expectEventValue("0123456789", "AFSpecial_Format(2)", "(012) 345-6789");
expectEventValue("0123456789", "AFSpecial_Format(3)", "012-34-5678");
app.alert("**********************");
expectError('', "AFSpecial_Keystroke()");
expectError('', "AFSpecial_Keystroke(65, 66)");
expectEventValue("abc", "AFSpecial_Keystroke(65)", "abc");
app.alert("**********************");
expectError('', "AFSpecial_KeystrokeEx()", '');
expectEventValue("12345", "AFSpecial_KeystrokeEx('')", "12345"); // No notification.
expectEventValue("123", "AFSpecial_KeystrokeEx('9999')", "123"); // Notifies invalid.
expectEventValue("12345", "AFSpecial_KeystrokeEx('9999')", "12345"); // Notifies too long.
expectEventValue("abcd", "AFSpecial_KeystrokeEx('9999')", "abcd"); // Notifies invalid.
expectEventValue("1234", "AFSpecial_KeystrokeEx('9999')", "1234");
expectEventValue("abcd", "AFSpecial_KeystrokeEx('XXXX')", "abcd");
app.alert("**********************");
expectError('', "AFTime_Format()");
expectError('', "AFTime_Format(1, 2)");
expectEventValue(0, "AFTime_Format(1)", "9:48 pm");
app.alert("**********************");
expectError('', "AFTime_FormatEx()");
expectError('', "AFTime_FormatEx('blooey', 42)");
expectEventValue(0, "AFTime_FormatEx('blooey')", "blooey");
app.alert("**********************");
expectError('', "AFTime_Keystroke()", '');
expectError('', "AFTime_Keystroke(1, 2)", '');
expectEventValue("12:03", "AFTime_Keystroke(65)", "12:03");
app.alert("**********************");
expectError('', "AFTime_KeystrokeEx()");
expectError('', "AFTime_KeystrokeEx(1, 2)");
expectEventValue("12:04", "AFTime_KeystrokeEx('blooey')", "12:04");
app.alert("*** ending test 1 ***");
} catch (e) {
app.alert("Truly unexpected error occured: " + e);
}
)
>>
endobj
{{object 18 0}} <<
/S /JavaScript
/JS (
// Re-run tests that depend on the "will commit" status of the event
// that triggered their execution.
try {
app.alert("*** starting test 2 ***");
expectError('', "AFDate_Keystroke()");
expectError('', "AFDate_Keystroke(1, 2)");
expectEventValue("04/19", "AFDate_Keystroke(2)", "04/19");
expectEventValue("04/19/15", "AFDate_Keystroke('blooey')", "04/19/15");
app.alert("**********************");
expectError('', "AFNumber_Keystroke()");
expectError('', "AFNumber_Keystroke(1)");
expectError("abc", "AFNumber_Keystroke(1, 2)");
expectEventValue("123", "AFNumber_Keystroke(1, 2)", "123");
expectEventValue("123", "AFNumber_Keystroke(1, 2, 3)", "123");
app.alert("**********************");
expectError('', "AFSpecial_KeystrokeEx()", '');
expectEventValue("12345", "AFSpecial_KeystrokeEx('')", "12345"); // No notification.
expectEventValue("123", "AFSpecial_KeystrokeEx('9999')", "123"); // Notifies invalid.
expectEventValue("12345", "AFSpecial_KeystrokeEx('9999')", "12345"); // Notifies too long.
expectEventValue("abcd", "AFSpecial_KeystrokeEx('9999')", "abcd"); // Notifies invalid.
expectEventValue("1234", "AFSpecial_KeystrokeEx('9999')", "1234");
expectEventValue("abcd", "AFSpecial_KeystrokeEx('XXXX')", "abcd");
app.alert("**********************");
expectError('', "AFMergeChange()");
expectError('', "AFMergeChange(1, 2)");
expect("one", "AFMergeChange(undefined)", "Aone");
app.alert("*** ending test 2 ***");
} catch (e) {
app.alert("Truly unexpected error occured: " + e);
}
)
>>
endobj
{{object 19 0}} <<
/S /JavaScript
/JS (
app.alert('Unexpected script 19');
)
>>
endobj
{{xref}}
{{trailer}}
{{startxref}}
%%EOF