Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First fixes and tests for IntlBidi. #1

Open
wants to merge 52 commits into
base: bidi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5ec8b65
Fixed return types for getReorderingMode() and getReorderingOptions().
scholz-timo Sep 27, 2018
873fb9d
Added embeddingLevels to IntlBidi::setPara()
scholz-timo Sep 27, 2018
6e423b8
Fixed IntlBidi::getReordered()
scholz-timo Sep 27, 2018
e6c2f6b
Added tests.
scholz-timo Sep 27, 2018
96f37e7
Updated parameter parsing to the fast paramter parsing api.
scholz-timo Sep 27, 2018
c85537b
Changed the call style of setLine to a java like approach and fixed t…
scholz-timo Sep 27, 2018
3bce63d
Added comment.
scholz-timo Sep 28, 2018
340151c
Removed duplicate in a test.
scholz-timo Sep 28, 2018
55c07f0
Removed unnecessary memory zeroing.
scholz-timo Oct 2, 2018
d785368
Made function arguments nullable.
scholz-timo Oct 2, 2018
3cd9c17
removed unnecessary emalloc calll, since erealloc with null has the s…
scholz-timo Oct 2, 2018
f67506f
Removed unnecessary comments and a unnecessary return
scholz-timo Oct 2, 2018
f26405c
Added tests.
scholz-timo Nov 20, 2018
6dcd0e4
Renamed error method.
scholz-timo Nov 20, 2018
8874440
Removed comments.
scholz-timo Nov 20, 2018
9229362
Use FQN in constant
JanSlabon Nov 20, 2018
e4f8844
Added Copyright notice and source informations.
scholz-timo Nov 20, 2018
2297451
Update ext/intl/tests/IntlBidi/IntlBidi_getBaseDirection_basic.phpt
JanSlabon Nov 20, 2018
172566d
Removed IntlBidi::getCustomizedClass() + code style.
scholz-timo Nov 20, 2018
2711a10
Deleted obsolete test
JanSlabon Nov 20, 2018
47bf076
Added Copyright notices to tests.
scholz-timo Nov 21, 2018
a84a7dc
Added and optimized various tests
JanSlabon Nov 21, 2018
da78f5e
Fixed bug in IntlBidi::setLine()
scholz-timo Nov 21, 2018
e45a197
Updated tests
scholz-timo Nov 21, 2018
c18d367
Updated test name
scholz-timo Nov 21, 2018
208aeb4
Removed zend-callstack object generation from IntlBidi::setLine()
scholz-timo Nov 21, 2018
757ceb5
Tweaks in tests
JanSlabon Nov 21, 2018
94e7812
Code style.
scholz-timo Nov 21, 2018
944e5d0
Merge branch 'bidi' of https://github.com/OmniFaR/php-src into HEAD
scholz-timo Nov 21, 2018
7243c93
Code style
JanSlabon Nov 21, 2018
8cedca2
Added test for inverse behavior
JanSlabon Nov 21, 2018
db9528b
Added test
JanSlabon Nov 21, 2018
7646902
Added and optimized various tests
JanSlabon Nov 21, 2018
54cbaa1
Added test for getVisualRun() method.
JanSlabon Nov 21, 2018
22c1f5d
Added test for IntlBidi::getProcessedLength() method
JanSlabon Nov 21, 2018
6b2a29e
Test optimizations
JanSlabon Nov 22, 2018
f984ec7
Implemented parent managemant.
scholz-timo Nov 30, 2018
47e7e36
Optimized Code style.
scholz-timo Nov 30, 2018
bd93331
Decoupled bidi instance from the zend_object.
scholz-timo Dec 3, 2018
a1692a4
Added parent instance management.
scholz-timo Dec 3, 2018
df21864
Added tests for maintaning bidi instances.
scholz-timo Dec 3, 2018
ef9f04e
Moved allocation logic in own function.
scholz-timo Dec 3, 2018
a0aa537
Code style and value type.
scholz-timo Dec 3, 2018
b2383dd
Code cleanup.
scholz-timo Dec 3, 2018
a95a639
Optimized test.
scholz-timo Dec 3, 2018
de68d04
Removed unnecessary space.
scholz-timo Dec 3, 2018
500c2d5
code cleanup.
scholz-timo Dec 4, 2018
456776c
Changed call order for freeing bidi_objects.
scholz-timo Dec 4, 2018
c61e4db
Merge branch 'bidi' of https://github.com/OmniFaR/php-src into HEAD
scholz-timo Dec 11, 2018
01d5c8b
Restructured specific setLine() test.
JanSlabon Dec 19, 2018
46e5c90
Fixed constructor and moved check into the constructor. Fixed nullabl…
scholz-timo Jan 29, 2019
69e133c
Added support for chained setLine() calls.
scholz-timo Jan 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 136 additions & 71 deletions ext/intl/bidi/bidi.c

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi___construct_basic.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
scholz-timo marked this conversation as resolved.
Show resolved Hide resolved
--FILE--
<?php
$bidi = new \IntlBidi();
?>
==DONE==
--EXPECT--
==DONE==
78 changes: 78 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi_basic.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
--FILE--
<?php
/**
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html#License
*
*******************************************************************************
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
/**
* Ported from Java.
* Original: https://github.com/unicode-org/icu/blob/master/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestReorder.java
*/

// include helper functions
include 'IntlBidi_ut_common.inc';

// the logical order of strings in a pseudo language.
$logicalOrder = [
'del(KC)add(K.C.&)',
'del(QDVT) add(BVDL)',
'del(PQ)add(R.S.)T)U.&',
'del(LV)add(L.V.) L.V.&',
'day 0 R DPDHRVR dayabbr',
'day 1 H DPHPDHDA dayabbr',
'day 2 L DPBLENDA dayabbr',
'day 3 J DPJQVM dayabbr',
'day 4 I DPIQNF dayabbr',
'day 5 M DPMEG dayabbr',
'helloDPMEG',
'hello WXY'
];

$nTests = \count($logicalOrder);
for ($testNumber = 0; $testNumber < $nTests; $testNumber++) {

// prepare the source.
$src = $logicalOrder[$testNumber];
// translate the pseudo language using a mapping.
$srcUt8 = pseudoToU8($src);

$bidi = new \IntlBidi();
$bidi->setInverse(true);

$levels = str_repeat("\0", IntlBidi::MAX_EXPLICIT_LEVEL);
for ($i = 0; $i < 10; $i++) {
$levels[$i] = chr($i + 1);
}

$bidi->setPara($srcUt8, \IntlBidi::DEFAULT_LTR, $levels);
$result = u8ToPseudo($bidi->getReordered(\IntlBidi::OUTPUT_REVERSE));
var_dump($result);
}
?>
==DONE==
--EXPECT--
string(17) ")K.C.&(KC)dda(led"
string(19) ")BVDL(ddaQDVT) (led"
string(21) "R.S.)T)U.&(PQ)dda(led"
string(22) "L.V.) L.V.&(LV)dda(led"
string(26) "rbbayad DPDHRVR R 0 yad"
string(27) "rbbayad DPHPDHDA H 1 yad"
string(28) "rbbayad DPBLENDA L 2 yad"
string(26) "rbbayad DPJQVM J 3 yad"
string(29) "rbbayad DPIQNF I 4 yad"
string(25) "rbbayad DPMEG M 5 yad"
string(10) "DPMEGolleh"
string(9) "WXY olleh"
==DONE==
77 changes: 77 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi_basic1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
--FILE--
<?php
/**
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html#License
*
*******************************************************************************
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
/**
* Ported from Java.
* Original: https://github.com/unicode-org/icu/blob/master/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestReorder.java
*/

include 'IntlBidi_ut_common.inc';

// --- INIT TEST DATA ---

$logicalOrder = [
'del(KC)add(K.C.&)',
'del(QDVT) add(BVDL)',
'del(PQ)add(R.S.)T)U.&',
'del(LV)add(L.V.) L.V.&',
'day 0 R DPDHRVR dayabbr',
'day 1 H DPHPDHDA dayabbr',
'day 2 L DPBLENDA dayabbr',
'day 3 J DPJQVM dayabbr',
'day 4 I DPIQNF dayabbr',
'day 5 M DPMEG dayabbr',
'helloDPMEG',
'hello WXY'
];

// --- RUN TEST ---

$nTests = \count($logicalOrder);
for ($testNumber = 0; $testNumber < $nTests; $testNumber++) {

// prepare the source.
$src = $logicalOrder[$testNumber];
$srcUt8 = pseudoToU8($src);

$bidi = new \IntlBidi();
$bidi->setInverse(true);
$levels = str_repeat("\0", IntlBidi::MAX_EXPLICIT_LEVEL);
for ($i = 0; $i < 10; $i++) {
$levels[$i] = chr($i + 1);
}
$bidi->setPara($srcUt8, \IntlBidi::DEFAULT_LTR, $levels);
$result = u8ToPseudo($bidi->getReordered(\IntlBidi::DO_MIRRORING | \IntlBidi::REMOVE_BIDI_CONTROLS));
var_dump($result);
}
?>
==DONE==
--EXPECT--
string(16) "del(add(CK(.C.K)"
string(19) "del( (TVDQadd(LDVB)"
string(20) "del(add(QP(.U(T(.S.R"
string(21) "del(add(VL(.V.L (.V.L"
string(26) "day 0 R RVRHDPD dayabbr"
string(27) "day 1 H ADHDPHPD dayabbr"
string(28) "day 2 L ADNELBPD dayabbr"
string(26) "day 3 J MVQJPD dayabbr"
string(29) "day 4 I FNQIPD dayabbr"
string(25) "day 5 M GEMPD dayabbr"
string(10) "helloGEMPD"
string(9) "hello YXW"
==DONE==
72 changes: 72 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi_getReordered_basic.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
--FILE--
<?php
/**
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html#License
*
*******************************************************************************
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
/**
* Ported from Java.
* Original: https://github.com/unicode-org/icu/blob/master/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestReorder.java
*/

include 'IntlBidi_ut_common.inc';

// --- INIT TEST DATA ---

$logicalOrder = [
'del(KC)add(K.C.&)',
'del(QDVT) add(BVDL)',
'del(PQ)add(R.S.)T)U.&',
'del(LV)add(L.V.) L.V.&',
'day 0 R DPDHRVR dayabbr',
'day 1 H DPHPDHDA dayabbr',
'day 2 L DPBLENDA dayabbr',
'day 3 J DPJQVM dayabbr',
'day 4 I DPIQNF dayabbr',
'day 5 M DPMEG dayabbr',
'helloDPMEG',
'hello WXY'
];

// --- RUN TEST ---

$nTests = \count($logicalOrder);
for ($testNumber = 0; $testNumber < $nTests; $testNumber++) {

// prepare the source.
$src = $logicalOrder[$testNumber];
$srcUt8 = pseudoToU8($src);

$bidi = new \IntlBidi();
$bidi->setPara($srcUt8, \IntlBidi::DEFAULT_LTR);
$result = u8ToPseudo($bidi->getReordered(\IntlBidi::DO_MIRRORING));
var_dump($result);
}
?>
==DONE==
--EXPECT--
string(17) "del(CK)add(&.C.K)"
string(19) "del(TVDQ) add(LDVB)"
string(21) "del(QP)add(S.R.)&.U(T"
string(22) "del(VL)add(V.L.) &.V.L"
string(26) "day 0 RVRHDPD R dayabbr"
string(27) "day 1 ADHDPHPD H dayabbr"
string(28) "day 2 ADNELBPD L dayabbr"
string(26) "day 3 MVQJPD J dayabbr"
string(29) "day 4 FNQIPD I dayabbr"
string(25) "day 5 GEMPD M dayabbr"
string(10) "helloGEMPD"
string(9) "hello YXW"
==DONE==
72 changes: 72 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi_getReordered_basic1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
--FILE--
<?php
/**
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html#License
*
*******************************************************************************
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
/**
* Ported from Java.
* Original: https://github.com/unicode-org/icu/blob/master/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestReorder.java
*/

include 'IntlBidi_ut_common.inc';

// --- INIT TEST DATA ---

$logicalOrder = [
'del(KC)add(K.C.&)',
'del(QDVT) add(BVDL)',
'del(PQ)add(R.S.)T)U.&',
'del(LV)add(L.V.) L.V.&',
'day 0 R DPDHRVR dayabbr',
'day 1 H DPHPDHDA dayabbr',
'day 2 L DPBLENDA dayabbr',
'day 3 J DPJQVM dayabbr',
'day 4 I DPIQNF dayabbr',
'day 5 M DPMEG dayabbr',
'helloDPMEG',
'hello WXY'
];

// --- RUN TEST ---

$nTests = \count($logicalOrder);
for ($testNumber = 0; $testNumber < $nTests; $testNumber++) {

// prepare the source.
$src = $logicalOrder[$testNumber];
$srcUt8 = pseudoToU8($src);

$bidi = new \IntlBidi();
$bidi->setPara($srcUt8, \IntlBidi::DEFAULT_LTR);
$result = u8ToPseudo($bidi->getReordered(\IntlBidi::DO_MIRRORING | \IntlBidi::OUTPUT_REVERSE));
var_dump($result);
}
?>
==DONE==
--EXPECT--
string(17) ")K.C.&(dda)KC(led"
string(19) ")BVDL(dda )QDVT(led"
string(21) "T(U.&).R.S(dda)PQ(led"
string(22) "L.V.& ).L.V(dda)LV(led"
string(26) "rbbayad R DPDHRVR 0 yad"
string(27) "rbbayad H DPHPDHDA 1 yad"
string(28) "rbbayad L DPBLENDA 2 yad"
string(26) "rbbayad J DPJQVM 3 yad"
string(29) "rbbayad I DPIQNF 4 yad"
string(25) "rbbayad M DPMEG 5 yad"
string(10) "DPMEGolleh"
string(9) "WXY olleh"
==DONE==
73 changes: 73 additions & 0 deletions ext/intl/tests/IntlBidi/IntlBidi_getReordered_basic2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
--TEST--
Regression test for the UBA implementation.
--CREDITS--
Timo Scholz <[email protected]>
--SKIPIF--
<?php if ( !extension_loaded('intl') ) print 'skip'; ?>
<?php if ( !extension_loaded('mbstring')) print 'skip'; ?>
--FILE--
<?php
/**
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html#License
*
*******************************************************************************
* Copyright (C) 2001-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
/**
* Ported from Java.
* Original: https://github.com/unicode-org/icu/blob/master/icu4j/main/tests/core/src/com/ibm/icu/dev/test/bidi/TestReorder.java
*/

include 'IntlBidi_ut_common.inc';

// --- INIT TEST DATA ---

$logicalOrder = [
'del(KC)add(K.C.&)',
'del(QDVT) add(BVDL)',
'del(PQ)add(R.S.)T)U.&',
'del(LV)add(L.V.) L.V.&',
'day 0 R DPDHRVR dayabbr',
'day 1 H DPHPDHDA dayabbr',
'day 2 L DPBLENDA dayabbr',
'day 3 J DPJQVM dayabbr',
'day 4 I DPIQNF dayabbr',
'day 5 M DPMEG dayabbr',
'helloDPMEG',
'hello WXY'
];

// --- RUN TEST ---

$nTests = \count($logicalOrder);
for ($testNumber = 0; $testNumber < $nTests; $testNumber++) {

// prepare the source.
$src = $logicalOrder[$testNumber];
$srcUt8 = pseudoToU8($src);

$bidi = new \IntlBidi();
$bidi->setInverse(true);
$bidi->setPara($srcUt8, \IntlBidi::DEFAULT_LTR);
$result = u8ToPseudo($bidi->getReordered(\IntlBidi::OUTPUT_REVERSE | \IntlBidi::INSERT_LRM_FOR_NUMERIC));
var_dump($result);
}
?>
==DONE==
--EXPECT--
string(22) "@)@K.C.&@(dda)@KC@(led"
string(24) "@)@BVDL@(dda )@QDVT@(led"
string(24) "R.S.)T)U.&@(dda)@PQ@(led"
string(25) "L.V.) L.V.&@(dda)@LV@(led"
string(28) "rbbayad @R DPDHRVR@ 0 yad"
string(29) "rbbayad @H DPHPDHDA@ 1 yad"
string(30) "rbbayad @L DPBLENDA@ 2 yad"
string(28) "rbbayad @J DPJQVM@ 3 yad"
string(31) "rbbayad @I DPIQNF@ 4 yad"
string(27) "rbbayad @M DPMEG@ 5 yad"
string(10) "DPMEGolleh"
string(10) "WXY@ olleh"
==DONE==
Loading